Error when trying to use Gmail for SMTP - Drupal 6.2
| Project: | SMTP Authentication Support |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | oadaeh |
| Status: | closed |
Jump to:
Hi,
Installed the latest SMTP module for Drupal 6 from here. I am using Drupal 6.2
Followed installation and download instructions in the README and got an error. Email was not sent. Contact site admin...
I was trying to configure it with gmail.
I went to Administer -> Site Configuration -> SMTP Authentication Support
Here are my inputs:
SMTP Server Settings
SMTP Server: smtp.gmail.com
SMTP Backup server:
SMTP Port: 465
Use Encrypted Protocol: Use SSL
SMTP Authentication
Username: myemail@gmail.com
Password: mypassword
E-mail Options
E-mail from address: root@rma.com
E-mail from name: My Name
Sent test email
Email address to send test email to: testemail@gmail.com
Then I pressed on "Save Configuration" and got this error:
* warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/rma/sites/all/modules/smtp/phpmailer/class.smtp.php on line 122.
* warning: fsockopen() [function.fsockopen]: unable to connect to :465 (Unknown error) in /var/www/rma/sites/all/modules/smtp/phpmailer/class.smtp.php on line 122.
* Unable to send e-mail. Please contact the site admin, if the problem persists.
So I decided to go back and change the port, as per Google's Instructions to 587, and retried. I got the mesage:
Unable to send e-mail. Please contact the site admin, if the problem persists.
So I went to the error logs, which said:
Error sending e-mail from myemail@gmail.com to testemail@gmail.com: SMTP Error: Could not connect to SMTP host.
I do not know how to proceed. How can I fix this? The built-in email thing (PHP Mail?) does not work, and the emailer is critical for my sites.
Any help or guidance would be GREATLY appreciated.
Thanks in advance,

#1
chx , of the drupal-support forum helped me shed some light on this. He said:
"You have not set up the phpmailer to use an existing SMTP server, one that resolves. That's it."
However, I'm still not sure how to do this and I have not found much documentation on this.
Can anybody here help me?
I would greatly appreciate it.
Thanks
#2
Wow! That's an incredibly detailed report. So much better than, "It's broke. Please fix it." Thank you for helping me find and fix this problem.
It turns out that I left some of the code that deals with the encryption protocol (ssl, tls or none) from 5.x version in the 6.x version of the module. I have corrected it, but it may be a while before the changes are in place. Look for an update of the file at http://drupal.org/node/279095 dated after July 6, 2008 - 17:08.
#3
Hey, thank YOU
It is in anyones best interest to write a detailed report when asking for support.
What do you make of this though:
"You have not set up the phpmailer to use an existing SMTP server, one that resolves. That's it."
Did you mean that you left out the automation? Will it work if I manually configure it to use an existing SMTP server? (which I have no clue how)
About the updates, looks like there is already one up past July 6. (at July 7, 2008 - 00:08)
"oadaeh - July 6, 2008 - 14:42
Nightly development snapshot from CVS branch: DRUPAL-6--1
Download: smtp-6.x-1.x-dev.tar.gz
Size: 11.15 KB
md5_file hash: ce749641c1ed9aac0a0838ae056b64fd
First released: July 6, 2008 - 14:42
Last updated: July 7, 2008 - 00:08"
Did you maybe mean updates after July 9th?
Thank you VERY much!
#4
I have no idea where that comes from. It might be coming from the server. When and where do you get it?
I don't know what you mean here. I didn't say anything about automation. What I changed was in the encryption selection code. If you leave the settings the way you had them in your original post, it should work as expected. I posted a detailed description for how to setup smtp.module for use with Gmail here: http://drupal.org/node/266048#comment-868081
Well, when I posted that comment, the date of the file was July 6, 2008 - 17:08 (and it still is for me), but yes, on or after July 9 would be correct.
#5
Okay. The update I committed was really for HEAD. I actually committed one for 6.x here.
#6
I'm getting the same or a similar problem trying to send through my google apps smtp server. I'm using the latest devshot (jul 18), drupal 6.3. I have tried various combinations of settings:
encryption: SSL
port: 465
"SMTP -> FROM SERVER: SMTP -> FROM SERVER: SMTP -> ERROR: EHLO not accepted from server: SMTP -> FROM SERVER: SMTP -> ERROR: HELO not accepted from server: SMTP -> ERROR: AUTH not accepted from server: SMTP -> FROM SERVER: SMTP -> ERROR: RSET failed: "
below this I also get:
"Unable to send e-mail. Please contact the site admin, if the problem persists."
encryption: SSL
port: 587
"SMTP -> ERROR: Failed to connect to server: (0) SMTP -> ERROR: Failed to connect to server: (-1073947372)"
below this I also get:
<?php* warning: fsockopen() [function.fsockopen]: SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol in /home/tom/public_html/drupal-6.x/public/sites/all/modules/smtp/phpmailer/class.smtp.php on line 122.
* warning: fsockopen() [function.fsockopen]: Failed to enable crypto in /home/tom/public_html/drupal-6.x/public/sites/all/modules/smtp/phpmailer/class.smtp.php on line 122.
* warning: fsockopen() [function.fsockopen]: unable to connect to <a href="//smtp.gmail.com:587" title="//smtp.gmail.com:587" rel="nofollow">ssl://smtp.gmail.com:587</a> (Unknown error) in /home/tom/public_html/drupal-6.x/public/sites/all/modules/smtp/phpmailer/class.smtp.php on line 122.
* warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/tom/public_html/drupal-6.x/public/sites/all/modules/smtp/phpmailer/class.smtp.php on line 122.
* warning: fsockopen() [function.fsockopen]: unable to connect to <a href="//:587" title="//:587" rel="nofollow">ssl://:587</a> (Unknown error) in /home/tom/public_html/drupal-6.x/public/sites/all/modules/smtp/phpmailer/class.smtp.php on line 122.
* Unable to send e-mail. Please contact the site admin, if the problem persists.
?>
encryption: TLS
port: 587
"SMTP -> FROM SERVER: SMTP -> FROM SERVER: SMTP -> ERROR: EHLO not accepted from server: SMTP -> FROM SERVER: SMTP -> ERROR: HELO not accepted from server: SMTP -> FROM SERVER: SMTP -> ERROR: STARTTLS not accepted from server: SMTP -> FROM SERVER: SMTP -> ERROR: RSET failed: SMTP -> FROM SERVER: SMTP -> ERROR: EHLO not accepted from server: SMTP -> FROM SERVER: SMTP -> ERROR: HELO not accepted from server: SMTP -> ERROR: AUTH not accepted from server: SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "" SMTP -> get_lines(): $data is "" SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "" SMTP -> get_lines(): $data is "" SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "" SMTP -> get_lines(): $data is "" SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "" SMTP -> get_lines(): $data is "" SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "" SMTP -> get_lines(): $data is "" SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "" SMTP -> get_lines(): $data is "" SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "" SMTP ->"
(this message repeats fo a long long time, and the browser hangs (firefox 3)
encryption: TLS
port: 465
nothing happened - the page said it was loading for over 5 minutes (but the borwser didn't freeze this time, and I got no error message)
#7
@mrfelton: your problem is different and should be under a different issue.
I have never had port 587 work for me. Both SSL and TLS work equally well on port 465. I assume you've set your settings similar to what I wrote up here: http://drupal.org/node/266048#comment-868081
You should also have gotten a message or two in the watchdog. what shows up there?
I'm betting this has something to do with your ISP or IP address or something similar. It looks like Google is rejecting you or your ISP.
BTW, I successfully sent myself several e-mails testing this out, using the above settings I referred to, so I know it works. I tried in several ways to make it fail so I could get the same error messages, but I never did (except for the port 587 ones).
#8
My settings were exactly as detailed in that comment you mention.
I access this google apps email account from this exact same machine via thunderbird, so I can't see how it could be blocking my IP. I'll take a look into the watchdog logs.
#9
In the error logs it says "Error sending e-mail from mylogin@mydomain.com to mylogin@mydomain.com : SMTP Error: Could not connect to SMTP host." after connecting with:
server: smtp.gmail.com
port: 465
encryption: SSL
username: mylogin@mydomain.com
Email from address: mylogin@mydomain.com
Note: I'm using mylogin@mydomain.com and not me@gmail.com since this is a goole apps email account - These are the same details that I use to successfully connect via Thunderbird from this same machine (except with Thundebird I use port 587)
#10
Okay, so what happens if you use
me@gmail.comfor the "Username" and it's password in the "Password" field, instead of themylogin@mydomain.comaddress? You don't have to change the "Email from address".#11
well, that wouldn't let me access my google apps email. But I tried it anyway with my standard gmail account and had exactly the same problems.
#12
I'm really stumped here. I have tried this on two different drupal sites, on two different servers (a total of 4 drupal installations), with the same error messages in return (as detailed above). I have tried with myname@mydomain.com (for my google apps account) as well as myname@googlemail.com (for my standard gmail account), both with combinations of TLS, SSL, port 465 and port 587. I have tried altering the email address that is detailed in Admin->Site Information. I always get the same darn errors.
Please, any help you could give would be much appreciated!
#13
I'm stumped as well, especially as I cannot recreate the problem in order to troubleshoot it. I've even installed Thunderbird and configured it to send through and receive from my Gmail account, in case that was causing your problem, but everything works as advertised.
Are both of the servers you mentioned using the same ISP, with possibly the same IP? Based on the error messages, I don't think it has anything to do with the installation of Drupal, so testing it on a second install on the same server should give you the same results. The error messages you are getting are coming from the SMTP server (Google, in this case) not any of the software in your Drupal install.
#14
I tried on two different machines, located in two different countries! One in Vietnam using DynDNS for a hostname, and the other on a Slicehost located in the states (Resolving to a .co.uk domain that I own) I'm gonna start disabling modules now incase something else is interfering. Perhaps I'm missing something with my DNS settings. Does my machine have to se set up in some specific way to be able to use gmails smtp server? It's just seems strange that I can connect with thunderbird, but not through drupal. :(
#15
There could be something with that. Google my flat out not like DynDNS (I have no idea), and your Slicehost resolving to your domain may be raising red flags. That would be something you would have to check with Google on.
My suspicion is that won't show anything, but it is worth a shot.
I don't think so, but that would be a Google issue, and you would have to check with them.
Is your Thunderbird install on one or both of the two servers? If not, then you aren't testing it in exactly the same environment, so it's an apples to oranges comparison.
#16
I'm closing this fixed bug report.
@mrfelton: if you are still having problems, create a new support request, as your problems are not the same as originally reported.
#17
Automatically closed -- issue fixed for two weeks with no activity.