sendEmail fails when using SMTP PLAIN Authentication

Bug #405733 reported by Dave on 2009-07-28
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
sendemail (Ubuntu)
Undecided
Unassigned

Bug Description

Binary package hint: sendemail

Expected: sendEmail sends the mail out using the specified server and credentials for SMTP AUTH

Reality: The server responds with a syntax error when PLAIN authentication is used -- which is the default if the server supports it. If the server response shows that the server does not support PLAIN but LOGIN, everything works fine.

Speculation: sendEmail does not generate the AUTH PLAIN string correctly before sending it to the server (line 1917 in /usr/bin/sendEmail). Or the 1&1 mail server is buggy.

Workaround: Make LOGIN the default (in /usr/bin/sendEmail: exchange lines 1914-1919 with lines 1921-1928, but preserve "if" and "elsif")

Note: TLS isn't used in this example (no SSL::Leay installed), but a test showed no difference with or without TLS.
Note: The AUTH PLAIN string has been altered (well, it contains username&password as base64), so I replaced it with a random string, but preserved the equal signs at the end. Also, all credentials and mail adresses have been altered.

Ubuntu release:
dave@truhe:~$ lsb_release -rd
Description: Ubuntu 9.04
Release: 9.04

Package Version:
dave@truhe:~$ apt-cache policy sendemail
sendemail:
  Installiert: 1.55-2
  Kandidat: 1.55-2
  Versions-Tabelle:
 *** 1.55-2 0
        500 http://de.archive.ubuntu.com jaunty/universe Packages
        100 /var/lib/dpkg/status

Command output:
dave@truhe:~$ sendEmail -v -v -f <email address hidden> -t <email address hidden> -u "Test Mail" -o username="*********" -o password="*******" -s "smtp.1und1.de" -o message-file=any_text.file
Jul 28 12:12:39 truhe sendEmail[14848]: DEBUG => Connecting to smtp.1und1.de:25
Jul 28 12:12:39 truhe sendEmail[14848]: DEBUG => My IP address is: 192.168.1.2
Jul 28 12:12:39 truhe sendEmail[14848]: DEBUG => evalSMTPresponse() - Found SMTP success code: 220
Jul 28 12:12:39 truhe sendEmail[14848]: SUCCESS => Received: 220 smtp.1und1.de (mreu1) Welcome to Nemesis ESMTP server
Jul 28 12:12:39 truhe sendEmail[14848]: INFO => Sending: EHLO truhe
Jul 28 12:12:40 truhe sendEmail[14848]: DEBUG => evalSMTPresponse() - Found SMTP success code: 250
Jul 28 12:12:40 truhe sendEmail[14848]: SUCCESS => Received: 250-smtp.1und1.de, 250-STARTTLS, 250-AUTH LOGIN PLAIN, 250-AUTH=LOGIN PLAIN, 250-PIPELINING, 250-SIZE 100000000, 250 HELP
Jul 28 12:12:40 truhe sendEmail[14848]: DEBUG => The remote SMTP server supports TLS :)
Jul 28 12:12:40 truhe sendEmail[14848]: DEBUG => SMTP-AUTH: Using PLAIN authentication method
Jul 28 12:12:40 truhe sendEmail[14848]: INFO => Sending: AUTH PLAIN HcJsiJkGdHjZhMJJjJIUGfHjFhvNmJnGtHfaaHuIlMjKgE3DD==
Jul 28 12:12:40 truhe sendEmail[14848]: DEBUG => evalSMTPresponse() - Found SMTP error code: 500
Jul 28 12:12:40 truhe sendEmail[14848]: ERROR => Received: 500 Syntax error - invalid character

Anik (clay) wrote :

You are correct about the assumption that the "AUTH PLAIN" string is not generated correctly. After some observation (I have very little Perl knowledge) it looks like sendEmail adds 0x0d0d0a, that's one 0x0d too much. It looks like the function base64_encode works incorrectly. It adds 0x0d0a after each 76 characters and then finally chomps the string once, and it looks like this does not delete the 0x0d.

My fix was to replace the chomp by a doubled chop:

833,834c833
< chop $data;
< chop $data;
---
> chomp $data;

This seems to fix it for me.

nandelbosc (nandelbosc-gmail) wrote :

Thank's Anik, yout mod works perfectly!

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers