in reply to Sending mail: setting envelope id

Hi, If I understand RFC3461 correctly the ENVID is just appended to the From-addres, their example is:
<<< 220 Example.ORG SMTP server here >>> EHLO Example.ORG <<< 250-Example.ORG <<< 250-DSN <<< 250-EXPN <<< 250 SIZE >>> MAIL FROM:<Alice@Example.ORG> RET=HDRS ENVID=QQ314159 <<< 250 <Alice@Example.ORG> sender ok >>> RCPT TO:<Bob@Example.COM> NOTIFY=SUCCESS \ ORCPT=rfc822;Bob@Example.COM <<< 250 <Bob@Example.COM> recipient ok >>> RCPT TO:<Carol@Ivory.EDU> NOTIFY=FAILURE \ ORCPT=rfc822;Carol@Ivory.EDU
so something like:
use Net::SMTP; my $smtp = Net::SMTP->new('mail.example.org'); $smtp->ehlo(); $smtp->mail('<Alice@Example.ORG> RET=HDRS ENVID=QQ314159'); $smtp->to('RCPT TO:<Bob@Example.COM> NOTIFY=SUCCESS ORCPT=rfc822;Bob@E +xample.COM '); $smtp->data(); $smtp->datasend('To: Alice@Example.ORG'); $smtp->datasend('Subject: test'); $smtp->data(); $smtp->datasend($your_message_here); $smtp->dataend(); $smtp->quit();
should do the trick. I haven't got a mailserver that supports the ENVID extension, so didn't test this.

Replies are listed 'Best First'.
Re^2: Sending mail: setting envelope id
by hv (Prior) on Jun 05, 2004 at 01:17 UTC

    Thanks for the suggestion. Rolling my own SMTP connection in that way seemed like too much work, so I ended up instead implementing the encoding specified by RFC 3461, and writing a little argument quoter (similar to Aristotle's) to let me invoke sendmail with a 2-arg open. Here is (roughly) the encoder:

    sub _quote_envid { local $_ = shift; # RFC 3461: max 100 chars, pass through printable ASCII characters e +xcluding # [ =+], encode others to '+XX' as uc(hex(ord($char))) s{([^\x21-\x7e]|[=+]))}{sprintf "+%02X", ord($1)}ge; # we're usually encoding an email address, so trim long strings from + front # to preserve the domain s/^(\+..|.)// while 99 < length; $_; }

    Hugo