in reply to Re: Sending mail: setting envelope id
in thread Sending mail: setting envelope id

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