Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Net::SMTP everything seems ok, but not sending

Status
Not open for further replies.

audibel

Programmer
Jun 27, 2007
3
US
I am trying to get Net:SMTP to work in perl, and I am not having any luck everything seems to be sending ok, but the email is not being recieved. I am very new with Perl, but am trying to get this working for functionality with a batch jpg to pdf conversion to (eventually) email attachments:

testmail.pl
Code:
use Net::SMTP;


      $smtp = Net::SMTP->new(
          'mail.that.com' ,
           Hello => 'mail.that.com',
           Timeout => 30,
           Debug   => 1,
       );


                      
      #  -- Enter email FROM below.   --
      $smtp->mail('this@that.com');

      #  -- Enter email TO below --
      $smtp->to('this@that.com');

      $smtp->data();

      #This part creates the SMTP headers you see
      $smtp->datasend("To: this\@that.com\n");
      $smtp->datasend("From: this\@that.com\n");
      $smtp->datasend("Content-Type: text/html \n");
      $smtp->datasend("Subject: A Test Message");
    
      # line break to separate headers from message body
      $smtp->datasend("\n");

      $smtp->datasend("Here is my test message body");

      $smtp->datasend("\n");
      $smtp->dataend();

      $smtp->quit;

The debug info is as follows:

Code:
C:\>perl testmail.pl
Net::SMTP>>> Net::SMTP(2.29)
Net::SMTP>>>   Net::Cmd(2.26)
Net::SMTP>>>     Exporter(5.58)
Net::SMTP>>>   IO::Socket::INET(1.29)
Net::SMTP>>>     IO::Socket(1.29)
Net::SMTP>>>       IO::Handle(1.25)
Net::SMTP=GLOB(0x19e6018)<<< 220 mail.that.com ESMTP
Net::SMTP=GLOB(0x19e6018)>>> EHLO mail.that.com
Net::SMTP=GLOB(0x19e6018)<<< 250-mail.that.com
Net::SMTP=GLOB(0x19e6018)<<< 250-8BITMIME
Net::SMTP=GLOB(0x19e6018)<<< 250 SIZE 16777216
Net::SMTP=GLOB(0x19e6018)>>> MAIL FROM:
Net::SMTP=GLOB(0x19e6018)<<< 250 sender  ok
Net::SMTP=GLOB(0x19e6018)>>> RCPT TO:
Net::SMTP=GLOB(0x19e6018)<<< 250 recipient  ok
Net::SMTP=GLOB(0x19e6018)>>> DATA
Net::SMTP=GLOB(0x19e6018)<<< 354 go ahead
Net::SMTP=GLOB(0x19e6018)>>> To: this@that.com
Net::SMTP=GLOB(0x19e6018)>>> From: this@that.com
Net::SMTP=GLOB(0x19e6018)>>> Content-Type: text/html
Net::SMTP=GLOB(0x19e6018)>>> Subject: A Test Message
Net::SMTP=GLOB(0x19e6018)>>> Here is my test message body
Net::SMTP=GLOB(0x19e6018)>>> .
Net::SMTP=GLOB(0x19e6018)<<< 250 ok:  Message 231350739 accepted
Net::SMTP=GLOB(0x19e6018)>>> QUIT
Net::SMTP=GLOB(0x19e6018)<<< 221 mail.that.com

It looks like the testmail.pl script opens smtp momentarily to send, but does not actually send a message to my mailbox. this and that are replaced with username and server obviously. It is my isp mail server, this should still work correct (My ISP server does not use AUTH. is there something that I am missing.
 
try sending an email how you would normally with your email client (outlook or whatever) to/from the same address with the same subject and message and see if it goes through.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Sent through Thunderbird it works fine. I don't have an SMTP server on my computer, but that is what Net::SMTP is able to do isn't it, use my ISP mail server to send email?
 
Yes, it should be able to. Your code looks OK to me. I don't know why you are not recieving the email if the "to" and "from" addresses are valid and the server does not use authentication. Proxies, firewalls?

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Well, I'm talking to isp tech support right now... and quote:

1:33:33 AM Louis: Sometimes there are issues sending on Port 25. You may have to use 465, but you would have to use a ssh connection with SSL. And authenticate.

So, this is way beyond my realm of knowledge right now, I think I can manage the authenticating but SSL, don't even know where to start.
 
Looks like you passed the message to the receiving SMTP server with no problems. I am positive the problem lies on their end. Whomever administers that mail server should be able to check the logs on their end and give a definitive answer.

It's either the mail server did something with the message after taking it (maybe thought it was spam?) or the user it's going to maybe has some sort of filtering set up in their client...

Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top