Problem with SMTP

Problem with SMTP

by Alejandro González -
Number of replies: 5

Hi mates, i am facing to a SMTP problem. I am trying to send a mail from moodle using SMTP server. The problem is that i tried with all of it and it's impossible to get it. I tried:

- Custom SMTP, and not working.

- Gmaill SMTP, not working.

- Php mail, its working.

Also I verify telnet through SSH, and it's gettin a response. Anyone can help me? My version is 3.5.


Average of ratings: -
In reply to Alejandro González

Re: Problem with SMTP

by Sanjay P. K. -
To use gmail for SMTP, you have to enable two factor authentication, generate an app password and use that instead of your regular gmail password.
In reply to Alejandro González

Re: Problem with SMTP

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi

> I am trying to send a mail from moodle

How exactly? Do you mean forum posts not going out as e-mail? Or (Moodle) messages not sent as e-mail? Or something else?

> using SMTP server.

Moodle always needs a SMTP server to sent e-mails out.

> The problem is that i tried with all of it and it's impossible to get it. I tried:

You don't need "all of it" (what are they?) just one way is enough. Let's take the first one:

> - Custom SMTP, and not working.

What is custom SMTP? Do you mean running a "Sendmail" on your localhost? Could you describe in more details how you configured, how you tested sending mails and how "not working" looks like?

> Also I verify telnet through SSH, and it's gettin a response.

"telnet through SSH"? Why do you need telnet if you have SSH? Do you mean you run 'telnet localhost 25' in an SSH terminal?
In reply to Visvanath Ratnaweera

Re: Problem with SMTP

by Alejandro González -

Hi guys,


Sanjay respect to two factors, i test a wamp server without that two factor and it works. It was too simply puting smtp config and testing with the email Test plugin. But I don't understand why from my vps is not working.

Visvanath I answer to your doubts:


> I am trying to send a mail from moodle

How exactly? Do you mean forum posts not going out as e-mail? Or (Moodle) messages not sent as e-mail? Or something else? 

    >>>> I tried with the email test plugin from my moodle, because from the chat neither was working. Then I decided to use the plugin.

The problem is that I have a moodle server at sered, but i bought a VPs server with Centos7 and I installed moodle on my own. All was working except that point (at this moment).


> using SMTP server.

Moodle always needs a SMTP server to sent e-mails out. 

        >>>> I mean with an own SMTP server (smtp.example.online) or I also tried with  smtp.google.com. Both with the ports.



> The problem is that i tried with all of it and it's impossible to get it. I tried:

You don't need "all of it" (what are they?) just one way is enough. Let's take the first one:
        >>>>> I mean that I tried all configurations that i know.

- Google 

Doesn't work.

- Own SMTP: The same but with the other SMTP. Doesn't work.

-I tried with the php sendermail default (without any data in outgoing mail): This works, but i want with my "own smtp", not with php sender. Works


When the email test doesn't work the log is:

"

2020-08-27 11:47:31	Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array()
2020-08-27 11:47:31	Connection failed. Error #2: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:
                   	                  error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed [/home/xxxxxx/public_html/moodles/lib/phpmailer/src/SMTP.php line 324]
2020-08-27 11:47:31	Connection failed. Error #2: stream_socket_client(): Failed to enable crypto [/home/xxxxxxx/public_html/moodles/lib/phpmailer/src/SMTP.php line 324]
2020-08-27 11:47:31	Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Unknown error) [/home/xxxxxxx/public_html/moodles/lib/phpmailer/src/SMTP.php line 324]
2020-08-27 11:47:31	SMTP ERROR: Failed to connect to server:  (0)
2020-08-27 11:47:31	SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

"
I was looking for a solution on internet, and I can't get any one. 

I have SSL with letsencrypt through whm configuration.


> - Custom SMTP, and not working.

What is custom SMTP? Do you mean running a "Sendmail" on your localhost? Could you describe in more details how you configured, how you tested sending mails and how "not working" looks like?

> Also I verify telnet through SSH, and it's gettin a response.

"telnet through SSH"? Why do you need telnet if you have SSH? Do you mean you run 'telnet localhost 25' in an SSH terminal?

      >>>>> Yes, write in a SSh terminal the command "telnet mail.****.***  25" and it connects.



Thx for your answers.

In reply to Alejandro González

Re: Problem with SMTP

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Test against your own SMTP server and watch its logs.

(You still have to explain, what "doesn't work" mean. I won't follow up any further.)

> write in a SSh terminal the command "telnet mail.****.*** 25" and it connects.

What is connects? The SMTP service sends its HELO message? Can you also type a complete mail and send it. Keep the log file of the SMTP showing "real-time" (tail -f /path/to/the/file).
In reply to Visvanath Ratnaweera

Re: Problem with SMTP

by Alejandro González -
Sorry Visvanath, my bad explication and thx for trying to understand it. With "doesn't work" i mean that email test doesn't work with that own SMTP (mail.****.***) neither gmail smtp. Own SMTP it's working in the other moodle... and I would like to work also here with it, or if it's not possible with gmail, but I wouldn't like to use php default (that it's the reason I am searching a solution for it).

With Gmail SMTP and telnet sends correct Helo message, I can't sent a complete email because when i write my password in base64 returns "535 Incorrect authentication data" (I tried my password and an app password, with 2 step).

I can't log because SMTP is from Sered, then I can't log it.

A lot of thx.