General help

Messaging: Gmail SMTP Setting Error,

 
 
Picture of Ramy Shokry
Messaging: Gmail SMTP Setting Error,
 

Dear all

I trying to send email copy yo the student using gmail account i try everything but i can't success yet, i using Moodle 1.9.9 i change class.smtp.php and upload it,as that page explain.

http://docs.moodle.org/22/en/Email_setup_gmail

at first I didn't change that line:

30: var $SMTP_PORT = 25;

it doesn't work so i change it to

30: var $SMTP_PORT = 465;

the same result it doesn't work!!

in that 2 cases i change line 82 to the following:

82: function Connect($host,$port=0,$tval=30) {$host = 'ssl://smtp.gmail.com:465' . $host;

and also i try with:

82: function Connect($host,$port=0,$tval=30) {$host = 'ssl://' . $host;

doesn't work too!!

but I notice Moodle sent pop up internal message, and nothing to the e-mail!!

and sent the message twice with the same time and date!!

any help!!

 
Average of ratings: -
Picture of Andrew Davis
Re: Messaging: Gmail SMTP Setting Error,
Group DevelopersGroup Moodle HQGroup Testers

Hi Ramy. I noticed one possible problem in what you've done that could be stopping this from working.

In the document where it says to enter the host as ssl://smtp.gmail.com:465 that is without making any code changes. Alternatively you could set $host to ssl://smtp.gmail.com:465 in code. However, the below looks like it is incorrect.

$host = 'ssl://smtp.gmail.com:465' . $host;

If you have a value like ssl://smtp.gmail.com:465 in the host field, then made that code change you'll wind up with the value of $host being ssl://smtp.gmail.com:465ssl://smtp.gmail.com:465 as it will append the existing value of $host to the hard coded string in the code.

 
Average of ratings: -
Picture of Ramy Shokry
Re: Messaging: Gmail SMTP Setting Error,
 

 Thank you Andrew for your reply,i'm really appreciate that smile

 I upload the original files again so that mean nothing change in the code and i fill the fields in site administration> Server>EMAIL as the following :

 SMTP host         : http://smtp.gmail.com:465

 SMTP username : myusername@gmail.com

 SMTP password : my password

 SMTP session limit : 1

 no reply address   : noreply@moodle.org

 Hour to send digest emails : 04

 Character set : UTF-8

 Allow user to select character set : NO

 Newline characters in mail : LF

 Support name : Ramy Shokry

 Support email : myusername@gmail.com

 Support page: empty

That's all i do what you think i missing??

 
Average of ratings: -
Picture of Dustin Horstmann
Re: Messaging: Gmail SMTP Setting Error,
 

The below should do it.

Make host ssl://smtp.gmail.com:465 in email settings. That is, add "ssl://".

Souce: http://docs.moodle.org/22/en/Email_setup_gmail

 
Average of ratings: -
Picture of Ramy Shokry
Re: Messaging: Gmail SMTP Setting Error,
 

I founad somethig interesting, maybe resolve that problem, go to Site Administration>Server>PHP info> Scroll down and find the next,

sendmail_from brij@ucvhost.com brij@ucvhost.com
sendmail_path no value no value
serialize_precision 100 100
short_open_tag On On
SMTP localhost localhost
smtp_port 25 25

if we could edit this data we can make SMTP work !!!

any help !!!!

 
Average of ratings: -
Picture of Ruslan Kabalin
Re: Messaging: Gmail SMTP Setting Error,
Group Developers

Hi Ramy,

This data can be changed in php.ini file or in apache config files using php_flag/php_value settings, but that will affect the whole site. You do not really need to change default php settings, as they will be ignored if you use Moodle SMTP settings.

In your particular case I would recommend to change settings in Site Administration -> Plugins -> Message outputs -> Email like specified in http://docs.moodle.org/22/en/Email_setup_gmail but ignore code modification bit from there:

SMTP hosts: smtp.gmail.com:465

SMTP username: Your email address @gmail.com or your own domain if using Google Apps

SMTP password: password for the above email account

Now open /lib/phpmailer/class.phpmailer.php and change line 199 from:

public $SMTPSecure    = '';

to

public $SMTPSecure    = 'ssl';

That should work, though would be great if you let me know if this worked for you. Also, make sure you do not use two-step autorisation in Gmail, in which case you need to generate application-specific password and use generated one, rather than using your standard password.

 

 

 
Average of ratings:Useful (1)
Picture of Ramy Shokry
Re: Messaging: Gmail SMTP Setting Error,
 

 Thank you Ruslan, I’m really appreciate your reply!

I’m follow your advice, but I using Moodle 1.9 I try to find  public $SMTPSecure    = '';     but I didn't find it in the code maybe there's difference between Moodle2 and Moodle1.9  code!!

I'm Already do not use two-step authorization in Gmail account, so do you think should I do!

 
Average of ratings: -
Picture of Ruslan Kabalin
Re: Messaging: Gmail SMTP Setting Error,
Group Developers

I see Ramy, that is true, I assumed you have 2.x, there is no public $SMTPSecure in phpmailer supplied with 1.9. For 1.9, the best is proboably to start with solution suggested in http://docs.moodle.org/22/en/Email_setup_gmail and check apache error log to see what goes wrong in case it will not work.

Regarding 2-step autorisation, I have just mentioned that your account password will not work if you authenticate from Moodle in case you use it, just something to keep in mind. If you do not use 2-step autorisation, then the standard google account password should work.

 
Average of ratings:Useful (1)
Picture of Ramy Shokry
Re: Messaging: Gmail SMTP Setting Error,
 

Thank you Ruslan, I try to found Apache setting on my website control panel but I just found PHP setting and I just can choose between 2 version 4.4.7 and 5.2.6 that I’m already work with.

So what you  think is doing the Apache work in the online website to modify.

 
Average of ratings: -
Picture of Lucas Ferreira
Re: Messaging: Gmail SMTP Setting Error,
 

Hello Ruslan

I tried as you said nothing happens just put the most errors, is as follows:

SMTP -> ERROR: Failed to connect to server: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution (0)

SMTP Error: Could not connect to SMTP host.

Could you help me?

Thank you!

 
Average of ratings: -
Picture of Ramy Shokry
Re: Messaging: Gmail SMTP Setting Error,
 

No one can resolve that problem till now!!

 
Average of ratings:Useful (1)
Picture of Anabel Service
Re: Messaging: Gmail SMTP Setting Error,
 

Has anyone solve this problem?

It's the same for my Moodle, but in this case the email account is an Exchange, but the error is the same:

"SMTP -> ERROR: Failed to connect to server: php_network_getaddresses: getaddrinfo failed

SMTP Error: Could not connect to SMTP host."

Thank u so much!

 
Average of ratings: -
Picture of Anabel Service
Re: Messaging: Gmail SMTP Setting Error,
 

I answer myself:

It was a DNS problem and it's fixed. After that we saw that we had to leave user and passwork empty because it didn't work if the fields were filled.

Thanks!

 
Average of ratings: -