SSL support - GMail
Artanicus@mythm... - November 28, 2005 - 11:55
| Project: | SMTP Authentication Support |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | critical |
| Assigned: | LukeLast |
| Status: | closed |
Description
The amount of non-SSL smtp servers is shrinking fast, and I for one don't have access to any non-SSL smtp servers thus making my life very much impossible with the poor SSL support of the php mailer and related systems.
Maybe you could save the day and implement support for ssl smtp connections?

#1
That sounds cool to me, do you know of any resources to start from?
#2
I would not be able to do this myself so unless someone can get the ball rolling I'll close the issue.
#3
Not only the amount of non-SSL smtp servers is shrinking fast, but GMail is asking SSL authentication (on port 465 currently) as stated in Configuring other mail clients.
So if someone is using Google Apps for Your Domain and need to use SMTP there is a possible solution.
First of all you have to check if ssl is enabled in your php configuration (look on php.ini or run phpinfo).
Then use attached patch. What it does?
Following a suggestion on phpmailer forum all that we need it's adding a protocol specification on fsockopen $host parameter. Instead of smtp.gmail.com we need to open ssl://smtp.gmail.com
So basically the patch change on SMTP
function Connect($host,$port=0,$tval=30)<?php#connect to the smtp server
$this->smtp_conn = fsockopen($host, # the host of the server
$port, # the port to use
$errno, # error number if any
$errstr, # error message if any
$tval); # give up after ? secs
?>
to
<?php
if($this->Protocol) $host = $this->Protocol."://".$host;
#connect to the smtp server
$this->smtp_conn = fsockopen($host, # the host of the server
$port, # the port to use
$errno, # error number if any
$errstr, # error message if any
$tval); # give up after ? secs
?>
Other small changes add parameter management (editing on drupal, adding on class definitions etc.).
Seems to work on drupal 4.7 (if someone is interested there is also a 4.6 patch).
#4
I got this error
warning: fgets() [function.fgets]: SSL: fatal protocol error in /var/www/drupal.hollocher.is-a-geek.com/modules/smtp/smtp.module on line 2775.
and the email did not send
#5
I'm sorry, the email did, in fact, send! I do get that warning, but the emails are being sent. Thanks.
#6
On the forum post there is another step that I didn't include in the patch:
Anyway mail is sent.
I googled around to find another solution but I failed :-(
#7
@ doesn't work.
I saw an error report for drupal somewhere mentioning that behavior in a different context. Maybe its a drupal bug.
Regardless, it looks like I will have to live with the error, which is fine.
Thanks!
#8
This looks very promising--I do have a question though--if your php.ini has no mention of ssl, what do I do? Running php 4, do I need to recompile that?
#9
Just wanted to report something here--it took me almost 2 weeks (of not constant) effort to figure this out:
Depending on where you look, google tells you to use smtp on port 465 or on 587. Turns out that 465 is ssl (not sure what version), and 587 is TLS. FYI--if you have a stable version of php4 or php5, you probably will not get this to work with TLS of 587. With 465, the error danbh reports does show up in your log, but the mails get sent. I didn't dig far enough--but this has something to do with how php can use STARTTLS.
#10
Thanks for all the great information.
HEAD has been updated to support SSL. It was working for me with gmail.
#11