Net::SMTP and orcpt

Discussion in 'Perl Misc' started by Matthew Braid, Jan 14, 2004.

  1. Hi all,

    I'm using Net::SMTP in a maillist manager, and I need to add some basic
    bounce-handling. I've decided to use the orcpt option in the rcpt
    commands, but I can't figure out how to do so.

    I looked at Net::SMTP's code and fiddled a bit, and added some code to
    the recipient function to accept address-specific options (at the moment
    just Original => addr) so you can do something like:

    $smtp->recipient(['',
    {Original => ''}]);

    which would generate a rcpt to line like:

    rcpt to:<> orcpt=rfc822;

    It will do the correct + quoting that is required for orcpt, eg +, =,
    ascii < 33, ascii > 126 become +ORD, where ORD is the 2 digit hex
    representation of ord(char), and it will carp if ESMTP is not supported
    (in the same fashion as the rest of Net::SMTP).

    I haven't tested it yet, but attached is a patch I made. Any comments?

    MB

    --- SMTP.pm Wed Jan 14 11:41:34 2004
    +++ /usr/local/lib/perl5/5.8.1/Net/SMTP.pm Thu Oct 16 10:38:45 2003
    @@ -327,20 +327,6 @@
    $me->_RSET();
    }

    -sub _orcpt {
    - my $self = shift;
    - my $orig = shift;
    - my $ret = ' orcpt=rfc822;';
    - for my $i (1..length($orig)) {
    - my $char = substr($orig, $i - 1, 1);
    - if ($char eq '=' or $char eq '+' or ord($char) < 33 or ord($char) > 126) {
    - $ret .= sprintf('+%02x', ord($char));
    - } else {
    - $ret .= $char;
    - }
    - }
    - return $ret;
    -}

    sub recipient
    {
    @@ -370,6 +356,7 @@
    carp 'Net::SMTP::recipient: DSN option not supported by host';
    }
    }
    +
    carp 'Net::SMTP::recipient: unknown option(s) '
    . join(" ", keys %opt)
    . ' - ignored'
    @@ -385,23 +372,7 @@
    my $addr;
    foreach $addr (@_)
    {
    - my ($raddr, $aopts) = ('', ' ');
    - if (ref($addr) eq 'ARRAY') {
    - if (not exists $esmtp->{DSN}) {
    - carp 'Net::SMTP::recipient: ESMTP not supported by host - address options discarded';
    - $raddr = $addr->[0];
    - } else {
    - my $opth;
    - ($raddr, $opta) = @$addr;
    - my $orig = delete($opta->{Original});
    - $aopts .= _orcpt($smtp, $orig) if defined $orig;
    - carp 'Net::SMTP::recipient: unknown address option(s) ' .
    - join(' ', keys %$opta) . ' - ignored' if scalar keys %$opta;
    - }
    - } else {
    - $raddr = $addr;
    - }
    - if($smtp->_RCPT("TO:" . _addr($smtp, $raddr) . $opts . $aopts)) {
    + if($smtp->_RCPT("TO:" . _addr($smtp, $addr) . $opts)) {
    push(@ok,$addr) if $skip_bad;
    }
    elsif(!$skip_bad) {
     
    Matthew Braid, Jan 14, 2004
    #1
    1. Advertising

  2. Sorry - accidentally cross-posted. See comp.lang.perl.modules
     
    Matthew Braid, Jan 14, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    1,131
    Roedy Green
    Jan 24, 2006
  2. Alex Hunsley
    Replies:
    4
    Views:
    3,690
    Tim Williams (gmail)
    Jun 29, 2004
  3. Raaijmakers, Vincent \(GE Infrastructure\)

    RE: sending of mail (smtp) - connection refused - but smtp serveris running!

    Raaijmakers, Vincent \(GE Infrastructure\), Jun 29, 2004, in forum: Python
    Replies:
    0
    Views:
    912
    Raaijmakers, Vincent \(GE Infrastructure\)
    Jun 29, 2004
  4. Copelandia Cyanescens

    smtplib.SMTP "no attributes SMTP"

    Copelandia Cyanescens, Jul 31, 2004, in forum: Python
    Replies:
    2
    Views:
    1,579
    Copelandia Cyanescens
    Jul 31, 2004
  5. tshad
    Replies:
    1
    Views:
    914
    bruce barker
    May 5, 2008
Loading...

Share This Page