cPanel Exim and Perl’s Net::SMTP::TLS

Another update: I have previously filed a bug on CPAN for this, and there are several similar posted there as well. https://rt.cpan.org/Ticket/Display.html?id=81215

UPDATE: This was a bug in Net::SMTP::TLS. I’ve included a patch below and also sending this along to the module author.

I noticed an issue recently with a script I have that sends emails through Perl’s Net::SMTP::TLS library. I’ve had this issue before, and I forgot how I fixed it. In any case, I’ve fixed it again.

Here’s my error from the Perl script:

1
EHLO command failed: 220 We do not authorize the use of this system to transport unsolicited,
2
at /usr/local/share/perl/5.12.4/SVN/Notify.pm line 2374

Here’s the headers I receive back from my SMTP server, a cPanel configured Exim server (real domain replaced with example.com):

1
$ telnet example.com 25
2
Connected to example.com.
3
Escape character is '^]'.
4
220-example.com ESMTP Exim 4.77 #2 Sun, 08 Apr 2012 12:59:07 +0400
5
220-We do not authorize the use of this system to transport unsolicited,
6
220 and/or bulk e-mail.
7

It looks to me like Perl’s not liking these additional lines. So let’s just rip them out. 

I changed the smtp_banner in /etc/exim.conf from 

1
smtp_banner = "${primary_hostname} ESMTP Exim ${version_number} \
2
\#${compile_number} ${tod_full} \n\
3
 We do not authorize the use of this system to transport unsolicited, \n\
4
 and/or bulk e-mail."

to 

1
smtp_banner = "${primary_hostname} ESMTP Exim ${version_number} \
2
\#${compile_number} ${tod_full}"

My subsequent headers then were only:

1
220 example.com ESMTP Exim 4.77 #2 Sun, 08 Apr 2012 16:11:21 +0400

Now Perl is happy to communicate with the server again. 

It looks like cPanel recently updated the Exim config in this case, which explains why this popped back up again. I’m assuming this is the same way I fixed it last time. 

1
# fgrep "exim.conf" /var/cpanel/updatelogs/update.133*
2
/var/cpanel/updatelogs/update.1333586462.log:[20120405.061343]   Retrieving /cpanelsync/11.32.2.15/cpanel/etc/exim/distconfig/exim.conf.dist.bz2
3
/var/cpanel/updatelogs/update.1333586462.log:[20120405.072810]      [28588] 2012-04-05 07:28:09 Exim configuration error in line 1111 of /etc/exim.conf:

I’m investigating if this is a bug in the Perl libraries, or cPanel’s exim config. I suspect in the Perl libraries. Sending system is Ubuntu 11.10; SMTP server is cPanel configured Exim on CentOS 5

1
$ perl -e "require Net::SMTP::TLS; print Net::SMTP::TLS->VERSION;"
2
0.12
3
$ perl -v
4
This is perl 5, version 12, subversion 4 (v5.12.4) built for x86_64-linux-gnu-thread-multi (with 45 registered patches, see perl -V for more detail)

Patch:

01
02
$ diff Net-SMTP-TLS-0.12/lib/Net/SMTP/TLS.pm  Net-SMTP-TLS-0.12-fixed/lib/Net/SMTP/TLS.pm 
03
117,121c117,126
04
<  # read the line immediately after connecting
05
<  my ($rsp,$txt) = $me->_response();
06
<  if(not $rsp == 220){
07
<  croak "Could not connect to SMTP server: $host $txt\n";
08
<  }
09
---
10
>  # read the line(s) immediately after connecting
11
>  my $rsp;
12
>  my $txt;
13
>  my $more;
14
>  do {
15
>  ($rsp,$txt,$more) = $me->_response();
16
>  if(not $rsp == 220){
17
>  croak "Could not connect to SMTP server: $host $txt\n";
18
>  }
19
>  } while ($more eq '-');
20

This entry was posted in Uncategorized. Bookmark the permalink.

One Response to cPanel Exim and Perl’s Net::SMTP::TLS

  1. Pwnall1337 says:

    the issue is that exim’s authentication requires binary zeros encrypted in base64, it’s quite sad really but something like this

    00user\@domain.com00password encrypt that in base64

    then
    smtp command

    EHLO
    AUTH PLAIN LOGIN

    Been trying to find a perl module for it but I might have to end up making one or hacking up some code.

Leave a Reply

Your email address will not be published. Required fields are marked *