title: Why does Perl's MIME::Lite fail with " SMTP data() command failed: 2.1.5 ... Recipient ok"?
body: <p>This is probably a crossover question that is valid for both SO and SF.
  I am using a Perl script as follows to send e-mail:</p>
  
  <pre><code>my $SMTP_SERVER = 'xx.xx.xx.xx'; 
  my $DEFAULT_SENDER = 'yyy@xxx.com';      
  my $DEFAULT_RECIPIENT = 'yyy@xxx.com';
  
  ### Create the multipart "container":
  $msg = MIME::Lite-&gt;new(
      From    =&gt;$DEFAULT_SENDER,
      To      =&gt;$input{to},
      Cc      =&gt;$DEFAULT_SENDER,
      Subject =&gt;$input{mailsubject},
      Type    =&gt;'multipart/mixed'
  );
  
  
  my $msgbody="&lt;body bgcolor=\"#C0C0C0\"&gt;\n";
     $msgbody.="&lt;img src="cid:xyz.gif"&gt;&lt;br&gt;O hai thar.."
     $msgbody.="&lt;/body&gt;";
  
  
  ### Add the text message part:
  ### (Note that "attach" has same arguments as "new"):
  $msg-&gt;attach(
      Type     =&gt;'text/html',
      Data     =&gt;$msgbody
  );
  
  ### Add the logo image part:    
  $msg-&gt;attach(
      Type =&gt; 'image/gif',
      Id   =&gt; 'xyz.gif',
      Path =&gt; '/var/www/images/xyz.gif',
  );
  
  
  ### Add the file part:
  $msg-&gt;attach(
      Type        =&gt;'application/zip',
      Path        =&gt;$input{fullpath},
      Filename    =&gt;$input{file},
      Disposition =&gt; 'attachment'
  );
  
  open ERROR,  '&gt;&gt;', "/debug/error.txt"  or die $!;
  STDERR-&gt;fdopen( \*ERROR,  'w' );
  
  eval{
  
  # send the email
  MIME::Lite-&gt;send('smtp', $SMTP_SERVER, Timeout=&gt;30, Debug=&gt;1, Notify =&gt; ['FAILURE','DELAY'], SkipBad =&gt; 1 );
  $msg-&gt;send();
  
  1;
  }
  or do{&amp;error($@)};
  
  close ERROR;
  </code></pre>
  
  <p>Now this script works lovely for 98% of the e-mails sent.. however.. the big 2% client is the one I am trying to figure out now. Whenever I send to this client in particular I get the message: <strong>SMTP data() command failed: 2.1.5 ... Recipient ok</strong> .</p>
  
  <p>Has anyone seen this error before or have any idea as to where my problem is? I tried replacing the X-Mailer: header thinking that was being spam filtered. I tried sending the same message to others on our domain and that works just not to this client URL.</p>
  
  <p>example header below:</p>
  
  <pre><code>MIME-Version: 1.0 
  Content-Transfer-Encoding: binary 
  Content-Type: multipart/mixed; 
  boundary="_----------=_12845827796770" 
  X-Mailer: MIME::Lite 3.027 (F2.76; T1.29; A2.03; B3.07_01; Q3.07) 
  Date: Wed, 15 Sep 2010 13:37:59 -0700 
  From: yyy@xxx.com 
  To: client1@clienturl.com, client2@clienturl.com, me@xxx.com 
  Cc: yyy@xxx.com 
  Subject: TEST
  </code></pre>
  
  <p>Any clues? </p>
  
  <p>Also, sending an e-mail directly using Outlook with same attachments works perfectly with this client and same smtp server. It is only when being sent via this automated process that the error rears it's ugly head.</p>
  
  <p><strong>Update:</strong> 
  Debug Log (which has me thinking it is a big latency issue where the responses are coming back asynch and hosing up the normal flow of operations in the process of MIME::Lite)</p>
  
  <pre><code>MIME::Lite::SMTP&gt;&gt;&gt; MIME::Lite::SMTP
  MIME::Lite::SMTP&gt;&gt;&gt;   Net::SMTP(2.31)
  MIME::Lite::SMTP&gt;&gt;&gt;     Net::Cmd(2.29)
  MIME::Lite::SMTP&gt;&gt;&gt;       Exporter(5.62)
  MIME::Lite::SMTP&gt;&gt;&gt;     IO::Socket::INET(1.31)
  MIME::Lite::SMTP&gt;&gt;&gt;       IO::Socket(1.30_01)
  MIME::Lite::SMTP&gt;&gt;&gt;         IO::Handle(1.27)
  MIME::Lite::SMTP=GLOB(0x84ac258)&lt;&lt;&lt; 220 smpt.xxx.com ESMTP Sendmail 8.12.9/8.13.1; Wed, 15 Sep 2010 16:50:44 -0700 (PDT)
  MIME::Lite::SMTP=GLOB(0x84ac258)&gt;&gt;&gt; EHLO localhost.localdomain
  MIME::Lite::SMTP=GLOB(0x84ac258)&lt;&lt;&lt; 250-smpt.xxx.com Hello [xx.xx.xx.xx], pleased to meet you
  MIME::Lite::SMTP=GLOB(0x84ac258)&lt;&lt;&lt; 250-ENHANCEDSTATUSCODES
  MIME::Lite::SMTP=GLOB(0x84ac258)&lt;&lt;&lt; 250-PIPELINING
  MIME::Lite::SMTP=GLOB(0x84ac258)&lt;&lt;&lt; 250-8BITMIME
  MIME::Lite::SMTP=GLOB(0x84ac258)&lt;&lt;&lt; 250-SIZE
  MIME::Lite::SMTP=GLOB(0x84ac258)&lt;&lt;&lt; 250-DSN
  MIME::Lite::SMTP=GLOB(0x84ac258)&lt;&lt;&lt; 250-ETRN
  MIME::Lite::SMTP=GLOB(0x84ac258)&lt;&lt;&lt; 250-DELIVERBY
  MIME::Lite::SMTP=GLOB(0x84ac258)&lt;&lt;&lt; 250 HELP
  MIME::Lite::SMTP=GLOB(0x84ac258)&gt;&gt;&gt; MAIL FROM:&lt;yyy@xxx.com&gt;
  MIME::Lite::SMTP=GLOB(0x84ac258)&lt;&lt;&lt; 250 2.1.0 &lt;yyy@xxx.com&gt;... Sender ok
  MIME::Lite::SMTP=GLOB(0x84ac258)&gt;&gt;&gt; RCPT TO:&lt;client1@clienturl.com&gt;
  [Wed Sep 15 16:41:22 2010] myemailscript.cgi: MIME::Lite::SMTP=GLOB(0x84ac258): Timeout at /usr/local/share/perl/5.10.0/MIME/Lite.pm line 2889
  MIME::Lite::SMTP=GLOB(0x84ac258)&gt;&gt;&gt; RCPT TO:&lt;client2@clienturl.com&gt;
  [Wed Sep 15 16:41:52 2010] myemailscript.cgi: MIME::Lite::SMTP=GLOB(0x84ac258): Timeout at /usr/local/share/perl/5.10.0/MIME/Lite.pm line 2889
  MIME::Lite::SMTP=GLOB(0x84ac258)&gt;&gt;&gt; RCPT TO:&lt;me@xxx.com&gt;
  [Wed Sep 15 16:42:22 2010] myemailscript.cgi: MIME::Lite::SMTP=GLOB(0x84ac258): Timeout at /usr/local/share/perl/5.10.0/MIME/Lite.pm line 2889
  MIME::Lite::SMTP=GLOB(0x84ac258)&gt;&gt;&gt; RCPT TO:&lt;yyy@xxx.com&gt;
  MIME::Lite::SMTP=GLOB(0x84ac258)&lt;&lt;&lt; 250 2.1.5 &lt;client1@clienturl.com&gt;... Recipient ok
  MIME::Lite::SMTP=GLOB(0x84ac258)&gt;&gt;&gt; DATA
  MIME::Lite::SMTP=GLOB(0x84ac258)&lt;&lt;&lt; 250 2.1.5 &lt;client2@clienturl.com&gt;... Recipient ok
  </code></pre>