[pskmail] Gmail smtp error fixed

  • From: Per Crusefalk <per@xxxxxxxxxxxx>
  • To: pskmail@xxxxxxxxxxxxx
  • Date: Sat, 31 Jan 2009 12:18:17 +0100

Hi all,

Rein has informed me that there is a problem with smtp tls through gmail
at the moment. Gmail is handy for those pskmail servers that can not
access their own smtp server, they can use gmail as a relay instead.

Smtp tls through gmail has worked fine with several servers but it seems
that gmail must have changed something, a return code, that smtp::tls
interprets as an error.

When I wrote that code I wanted it to be verbose and explain any error
in detail right away. That means every step of the process is checked
for errors and the send is aborted right away when an error occurs.

So, the old code will check that the sender address is ok with the
smtpserver (gmail):

        ### Begin transaction ###
        if ( !$smtp->mail( $from ) ) {
                logprint ("sender not accepted\n");
                exit 1;
        }

So, if the smtp server is not happy with the from address then it should
inform abt it right away (to make the debug procedure simple) and abort.

This has been fine but now the send is aborted right away.
I have checked other implementations of this and "all" others seem to
just not care abt what the server returns. And, indeed, if I stop double
checking everything and just check the overall process for serious
errors then it works. By that I mean that I remove the extra checks and
just dive right in:

        ### Begin transaction ###
        $smtp->mail( $from );
        $smtp->to( $to );
        # Send the data
        $smtp->data;
        $smtp->datasend("To: $to\n");
        $smtp->datasend("From: $from\n");
        $smtp->datasend("Date: $mydate\n");
        $smtp->datasend("Subject: $subject\n");
        $smtp->datasend("\r\n");
        foreach (@body) {
                 $smtp->datasend("$_\n");
        }
        $smtp->dataend;
        $smtp->quit;

That works fine, and I can still eval the entire process for errors.

Also, I have added a timeout parameter so that it wont hang if there is
no reply from the smtp server within 10 seconds. 

Rein:
I have updated the file and will stress test it further and then check
in and notify you. Also, only port 587 seems to work at the moment.

73 de Per, sm0rwo






Other related posts:

  • » [pskmail] Gmail smtp error fixed - Per Crusefalk