ironcamel / Dancer-Plugin-Email

Simple email sending for Dancer
http://p3rl.org/Dancer::Plugin::Email
6 stars 10 forks source link

added possibility to set sender address #19

Closed fany closed 10 years ago

fany commented 10 years ago

As stated in Email::Sender::Manual::QuickStart, it is sometimes necessary to be able to set the e-mail sender (e.g. MAIL FROM in the envelope) to a different address than the address given in the From header line.

This patch enables you to do this by passing a "sender" key to Dancer::Plugin::Email. I am not sure, if this is the most reasonable implementation, though – suggestions welcome!

ironcamel commented 10 years ago

I don't think your code does what you described. You are just overwriting the from field with the sender:

+    $sendmail_arg{from} = $sender if defined $sender;

What am I missing?

fany commented 10 years ago

I don't think your code does what you described. You are just overwriting the from field with the sender:

+    $sendmail_arg{from} = $sender if defined $sender;

What am I missing?

%sendmail_arg is later passed as second argument to the sendmail() function imported from Email::Sender::Simple:

 return sendmail $email, \%sendmail_arg;

This function expects the envelope sender like this, see example at http://metacpan.org/pod/Email::Sender::Manual::QuickStart#envelope-information

The From header field is passed in the $email object and is not influenced by my change.

Regards, fany

ironcamel commented 10 years ago

I see now. Thanks!