Messaging: Gmail SMTP Setting Error,

Messaging: Gmail SMTP Setting Error,

by Ramy Shokry -
Number of replies: 14

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: -
In reply to Ramy Shokry

Re: Messaging: Gmail SMTP Setting Error,

by Andrew Davis -

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.

In reply to Andrew Davis

Re: Messaging: Gmail SMTP Setting Error,

by Ramy Shokry -

 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??

In reply to Ramy Shokry

Re: Messaging: Gmail SMTP Setting Error,

by Dustin Horstmann -

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

In reply to Dustin Horstmann

Re: Messaging: Gmail SMTP Setting Error,

by Ramy Shokry -

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 !!!!

In reply to Ramy Shokry

Re: Messaging: Gmail SMTP Setting Error,

by Ruslan Kabalin -
Picture of Core developers Picture of Moodle HQ Picture of Moodle Workplace team Picture of Peer reviewers Picture of Plugin 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)
In reply to Ruslan Kabalin

Re: Messaging: Gmail SMTP Setting Error,

by Ramy Shokry -

 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!

In reply to Ramy Shokry

Re: Messaging: Gmail SMTP Setting Error,

by Ruslan Kabalin -
Picture of Core developers Picture of Moodle HQ Picture of Moodle Workplace team Picture of Peer reviewers Picture of Plugin 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)
In reply to Ruslan Kabalin

Re: Messaging: Gmail SMTP Setting Error,

by Ramy Shokry -

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.

In reply to Ruslan Kabalin

Re: Messaging: Gmail SMTP Setting Error,

by Lucas Ferreira -

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!

In reply to Ramy Shokry

Re: Messaging: Gmail SMTP Setting Error,

by Ramy Shokry -

No one can resolve that problem till now!!

Average of ratings: Useful (1)
In reply to Ramy Shokry

Re: Messaging: Gmail SMTP Setting Error,

by Anabel Service -

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!

In reply to Anabel Service

Re: Messaging: Gmail SMTP Setting Error,

by Anabel Service -

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!

In reply to Anabel Service

Re: Messaging: Gmail SMTP Setting Error,

by Bhimreddy M -

Hi,

We hosted a moodle on Redhat Linux 5 and we are using as localhost. For that we are trying to configure SMTP.

Default php mail is working and showing mail sent, but its not delivering to the receiver.

Then  i configured SMTP using gmail but its not working, giving the error as incorrect SMTP configuration.

Is it because of the localhost.?

Could you please tell us how to configure with DNS.

In reply to Anabel Service

Re: Messaging: Gmail SMTP Setting Error,

by Bhimreddy M -
hey could you tell us how u fixed DNS problem. we also facing same problem.

I am using moodle 3.0 on redhat linux .

i am facing a problem with No Email confirmation for self Registration.


When i tried to create new account through email base registration it showing email has been sent, but its not delivering to the reviver 


then i tried to configure SMTP using gmail .its showing Tried to send you an email but failed! 

could you please tell us solution.