开发者

Why can't I send mail with Perl's Net::SMTP?

I use Net::SMTP to automate emails. I want to get notification if someone use email into Outlook I used this:

  $smtp->datasend("Disposition-Notification-To: to.me\@domain.com");

The email sent succesfully but the Outlook client is not getting the 开发者_开发知识库notification.

Here is a snippet of the code:

$smtp = Net::SMTP->new("my mail host");
$smtp->mail("my\@adress.com);
$smtp->to("someuser@domain.com");
$smtp->data();
$smtp->datasend("Disposition-Notification-To:my\@adress.com");
$smtp->datasend("blah balh");
$smtp->datasend();
$smtp->quit;


The Net::SMTP module is pretty low level for this sort of stuff. You'd have an easier time with a higher level module such as Email::Sender.


It's possible the Outlook client agent is not set up properly to listen for these events. Can you send mail to it via another method? You need to isolate whether it is the listener or the sender that is having problems.

If you can receive mail in Outlook, but just not from your code, then it's your code at fault. Please include more contextual code in your question -- e.g. how is the $smtp object being constructed? Are you making a $smtp->dataend(); call as per the documentation?

Edit (after you included some code): there is a typo in that code; are you using use strict; use warnings; at the top of your script or module? Can you receive mail to your client from other means?

Edit2: if notification is all you're lacking, you should probably dive into the Outlook documentation to see what the criteria are for receiving such notification. e.g. you might need to provide a valid "Date:" header.


You need to include a blank line between the last header and the actual body of the message.

You also seem to be missing a space after the header prefix.

I'd guess that one of these is stopping Outlook from interpreting the header correctly.

Try this:

$smtp->data();
$smtp->datasend("From: my\@address.com");
$smtp->datasend("To: my\@address.com");
$smtp->datasend("Subject: test mail");
$smtp->datasend("Disposition-Notification-To: my\@adress.com");
$stmp->datasend("\n");
$smtp->datasend("blah blah");
$smtp->dataend();
$smtp->quit;


Perhaps Outlook is requiring the Return-Receipt-To header (non-standard, but you are sending to Outlook, afterall).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜