Simple Machines Community Forum

SMF Development => Bug Reports => Fixed or Bogus Bugs => Topic started by: Stefan1200 on February 10, 2013, 04:46:30 AM

Title: Mail sending with SMF 2.0.4 to a SSL SMTP server on SourceForge
Post by: Stefan1200 on February 10, 2013, 04:46:30 AM
Using SMF 2.0.4 on SourceForge Project Web. While setting up the sourceforge mail server I ran into problems.

Only with the following settings SMF got a connection to the mail server:
Mail Host: ssl://prwebmail
Mail Port: 465
User and Password Settings of course.
With this settings I get a connection to the mail server, but no mails will be send because of this error:

< 220 sfp-mx-1.v30.ch3.sourceforge.com ESMTP Exim 4.72 Sun, 10 Feb 2013 09:38:01 +0000
> EHLO ssl://prwebmail
< 501 Syntactically invalid EHLO argument(s)
> HELO ssl://prwebmail
< 501 Syntactically invalid HELO argument(s)


Problem is that SMF send the ssl:// stuff as EHLO command, that is wrong.

I did small modifications to the Subs-Post.php file, now it works (stars just escape secret informations :)):

< 220 sfp-mx-1.v30.ch3.sourceforge.com ESMTP Exim 4.72 Sun, 10 Feb 2013 09:30:41 +0000
> EHLO prwebmail
< 250 HELP
> AUTH LOGIN
< 334 ***
> ***
< 334 ***
> ***
< 235 Authentication succeeded
> MAIL FROM: <***@***.***>
< 250 OK
> RCPT TO: <***@***.***>
< 250 Accepted
> DATA
< 354 Enter message, ending with "." on a line by itself
> .
< 250 OK id=1U4TFC-0003Gg-Gj


My modification (function smtp_mail starting on line 1353):

$smtpHost = $modSettings['smtp_host'];
if (substr($smtpHost, 0, 6) == "ssl://" || substr($smtpHost, 0, 6) == "tls://")
{
$smtpHost = substr($smtpHost, 6);
}

if ($modSettings['mail_type'] == 1 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '')
{
// !!! These should send the CURRENT server's name, not the mail server's!

// EHLO could be understood to mean encrypted hello...
if (server_parse('EHLO ' . $smtpHost, $socket, null) == '250')
{
if (!server_parse('AUTH LOGIN', $socket, '334'))
return false;
// Send the username and password, encoded.
if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334'))
return false;
// The password is already encoded ;)
if (!server_parse($modSettings['smtp_password'], $socket, '235'))
return false;
}
elseif (!server_parse('HELO ' . $smtpHost, $socket, '250'))
return false;
}
else
{
// Just say "helo".
if (!server_parse('HELO ' . $smtpHost, $socket, '250'))
return false;
}


Maybe this change would be useful in a future version of SMF?
Title: Re: Mail sending with SMF 2.0.4 to a SSL SMTP server on SourceForge
Post by: Arantor on February 11, 2013, 12:17:54 AM
I'm not entirely sure it would. All the information I've seen on this issue suggests that the protocol should be left in - every example outside of SourceForge has shown it with that indicated. Though most of those seemed to use a wrapper library, whose innards are not necessarily clear.

I also think if it were more clearly a problem, then it would be more widespread. Of course, instead of patching it to remove the protocol from the host you could just have not entered it in the first place?
Title: Re: Mail sending with SMF 2.0.4 to a SSL SMTP server on SourceForge
Post by: Stefan1200 on February 14, 2013, 02:31:01 PM
Quote from: Arantor on February 11, 2013, 12:17:54 AM
Of course, instead of patching it to remove the protocol from the host you could just have not entered it in the first place?

Does not work.

What says the RFC of the SMTP protocol, with or without ssl:// as prefix? That's the important question.
Title: Re: Mail sending with SMF 2.0.4 to a SSL SMTP server on SourceForge
Post by: Fisch.666 on April 19, 2013, 05:37:04 AM
Hi,

had the same problem here with my own mailserver:

Quote
501 5.5.2 <ssl://domain>: Helo command rejected: Invalid name

because SMF is using the protocol ssl:// (when defined) in the HELO / EHLO commands. According to the RFC 2821 (https://www.ietf.org/rfc/rfc2821.txt) on Page 29 this commands must be used:


   Syntax:

      ehlo            = "EHLO" SP Domain CRLF
      helo            = "HELO" SP Domain CRLF


so appending the protocol seems to be wrong. Thanks to the changes from Stefan1200 this is now working for me.