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?

Files: 
CommentFileSizeAuthor
#3 smtp47.patch659 bytesEmanueleQuinto

Comments

That sounds cool to me, do you know of any resources to start from?

Status:Active» Closed (fixed)

I would not be able to do this myself so unless someone can get the ball rolling I'll close the issue.

Title:SSL supportSSL support - GMail
Version:5.x-1.x-dev» 4.7.x-1.x-dev
Status:Closed (fixed)» Needs review
StatusFileSize
new659 bytes

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).

Status:Needs review» Needs work

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

Status:Needs work» Needs review

I'm sorry, the email did, in fact, send! I do get that warning, but the emails are being sent. Thanks.

On the forum post there is another step that I didn't include in the patch:

3. change to fgets() to @fgets() to surpass the ssl error

Anyway mail is sent.

I googled around to find another solution but I failed :-(

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

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?

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.

Version:4.7.x-1.x-dev» 5.x-1.x-dev
Assigned:Unassigned» LukeLast
Status:Needs review» Fixed

Thanks for all the great information.

HEAD has been updated to support SSL. It was working for me with gmail.

Status:Fixed» Closed (fixed)