http://www.perlmonks.org?node_id=861888

The ISP/cable provider Comcast blocks port 25 on its SMTP service for customers, requires password authentication and also, it turns out, doesn't like people using server names in the MAIL FROM field of the SMTP handshake. This last presents a problem as Mail::Mailer::smtp is hard wired to use the results of Mail::Util's mailaddress in the 'From' field. Mail::Mailer transmission modules, however, can be usefully subclassed, so the following works to send mail to Comcast:

mkdir -p lib/Mail/Mailer/smtp

And then create in this directory the file From.pm

package Mail::Mailer::smtp::From; use base Mail::Mailer::smtp; sub exec { my ($self, $exe, $args, $to) = @_; my %opt = @$args; my $host = $opt{Server} || undef; $opt{Debug} ||= 0; my $smtp = Net::SMTP->new($host, %opt) or return undef; if($opt{Auth}) { $smtp->auth(@{$opt{Auth}}) or return undef; } ${*$self}{sock} = $smtp; # # Adding a patch to set the From Address.. # $smtp->mail($self->mailaddress); $smtp->mail( $opt{From} ) if $opt{From}; # # End patch. # $smtp->to($_) for @$to; $smtp->data; untie *$self if tied *$self; tie *$self, 'Mail::Mailer::smtp::pipe', $self; $self; } 1;

And then you can send files to Comcast using code equivalent to this:

#! /usr/bin/perl use warnings; use strict; use lib './lib'; use Mail::Mailer::smtp::From; use Mail::Send; my $msg= Mail::Send->new; $msg->to('An@Address'); $msg->subject('Test Code'); my $fh = $msg->open('smtp::From', Server => 'smtp.comcast.net', Auth => [ 'user','pass' ], Port => 587, From => 'me@comcast.net', Debug => 1 ); print $fh "This is a test message.\n"; $fh->close or die("Could not send message.\n");

Replies are listed 'Best First'.
Re: Getting Mail::Send to work with Comcast
by Anonymous Monk on Sep 24, 2010 at 22:45 UTC
    The ISP/cable provider Comcast blocks port 25 on its SMTP service for customers, requires password authentication and also, it turns out, doesn't like people using server names in the MAIL FROM field of the SMTP handshake.

    Any ISP that goes through all that trouble, also has it against the rules to circumvent this process, and will usually terminate your account if get smart

      That's one way of looking at it, but the python library smtplib works out of the box and seamlessly with Comcast.

      Personally, whether my code is written in python or Perl, I'd rather vote in favor of all my languages Just Working.

      David.

        One thing has nothing to do with the other
Re: Getting Mail::Send to work with Comcast
by Mr. Muskrat (Canon) on Sep 27, 2010 at 21:22 UTC

    I think that you would be better off working with Comcast to overcome their shortcomings than attempting to work around them.

    When I was a Comcast customer, they had a way of opting out of the SNMP weirdness. I had to enter a support ticket and then talk to someone at tier 2 or tier 3 support and explain why I wanted to opt out of the "security features".