views:

113

answers:

4

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("[email protected]");
$smtp->data();
$smtp->datasend("Disposition-Notification-To:my\@adress.com");
$smtp->datasend("blah balh");
$smtp->datasend();
$smtp->quit;
+1  A: 

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.

Ether
I recieve email on the outlook from my code but i don't recieve Notification .
dan
A: 

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;
mopoke
+1  A: 

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.

brian d foy
Email::Send seems deprecated as said in its CPAN page, use Email::Sender instead...
sebthebert
A: 

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

MkV