in reply to Re: Net::SMTP and debugging ?
in thread Net::SMTP and debugging ?

Hi,

Thanks for putting me onto CGI::Carp, it has been great to be able to see _where_ the script is crashing. I just directed the log file to a path I could view via a browser, as SSH access take foreever to load.

I've now been able to use Net::SMTP successfully, once I put "localhost" as the domain/mailserver, it worked like a charm. The only problem I found was I could not do this

$from = 'sales@domain.com'; $toaddress = 'fredflintstone@disney.com'; $name = 'Fred Flintstone'; $smtp->mail('$from\n"); $smtp->to("$toaddress\n");

but got around the problem by putting email headers like this

$smtp->data(); $smtp->datasend("To: $name <$toaddress>\n"); $smtp->datasend("Subject: Confirmation and Thankyou\n"); $smtp->datasend("X-Order-IP: $ENV{REMOTE_ADDR}\n"); $smtp->datasend("\n"); $smtp->datasend("Hi $name,\n");

Peter

Replies are listed 'Best First'.
Re: Re: Re: Net::SMTP and debugging ?
by demerphq (Chancellor) on Oct 06, 2003 at 11:22 UTC

    Glad CGI::Carp was helpful. However I must say that I strongly discourage hand generating SMTP mails. Use MIME::Lite instead. Let it do the work of making sure things are set up correctly.

    The new version will have much more powerful features for handling SMTP transport, but you dont need any of those features from what I can tell.


    ---
    demerphq

      First they ignore you, then they laugh at you, then they fight you, then you win.
      -- Gandhi


      Glad CGI::Carp was helpful

      Yes, after seeing "premature end of scripts headers" for a long while, and _not_ knowing where it crashes, has been very fustrating. Now I can see warning messages, and for testing the email, I can see ALL the echos back from the email server.

      However I must say that I strongly discourage hand generating SMTP mails. Use MIME::Lite instead. Let it do the work of making sure things are set up correctly.

      Although the Net::SMTP has been working 100% okay for a small Perl script (about 170 lines, most of it email 'body'), when I added it to a much larger Perl script, as a sub routine, it is not working all the time. From the 'logs', the email server is talking okay, and I should get all the emails back, but I don't. On the converse, the 'feedback' form, which uses FormMail.pl and the CGI::NMS::Mailer::SMTP modules, it works 100% on 2 domains ??

      So, there is something strange happening with Net::SMTP, and because the emails are online order confirmations, I _really_ need them ALL to come to me first. I had a quick look at MIME:Lite, it looks very easy to use. We have Perl 5.61, so I hope it is installed, so that I can test it. The emails I'm sending aren't complex (attachments will be later), they are just a few standard email headers, and the body is a mixture of 'fixed' text, plus some text created from some MySQL work.

      Thanks, :)

      Peter

      Use MIME::Lite instead

      Well, thanks, a small one line test worked just fine, no authentication needed, and the headers look more like the (NMS) FormMail.pl headers. The website does state they have SENDMAIL, but they _actually_ use Exim. I just used the example for the headers and the body, and then

      $msg->send;
      Looks like that's all I need. As there is quite a lot of email 'body', is the best way to do multiple

      Data =>"Some test in the body part" )

      .. or some other preferred method, considering there are a few MySQL 'FOR' loops to build parts of the email body.

      Thanks,

      Peter