Got a strange one. I am trying to send mail to clients when their radio station goes down. It works when the email is within the SMTP server domain but not externally. So if my SMTP server is collins.com and my email is chris@collins.com and I set the TO: field to joe@collins.com everything works fine. If the TO: filed is joe@comcast.net nothing ever gets through. Any bright Ideas?
sub MailSmtp { my $settings = shift(@_); my $stationNumber = shift(@_); my $from = $settings->{fromEmail}; my $reply = $settings->{replyEmail}; my @to = split(/,/,$settings->{emailGroup}); my $subject; my $user = $settings->{user}; my $pass = $settings->{pass}; my $port; if (exists $settings->{port}) { $port = $settings->{port}; }else{ $port = 25; } my $status = $settings->{ports}->{$stationNumber}->{status}; my $relay = $settings->{smtp}; my $smtp; $subject = $settings->{ports}->{$stationNumber}->{id}; $subject = $subject . " is " . $status; my $message = $settings->{message}; $smtp = Net::SMTP->new($relay,Port => $port,Debug => 0,) ; if (!$smtp) { print "\t--[ Could not connect to the email server\n"; return; } $smtp->auth ( $user, $pass); $smtp->mail($from); # use the sender's address here $smtp->recipient($me); # recipient's address $smtp->data(); # Start the mail # Send the header. for $to (@to) { $smtp->datasend("To: $to\n"); } $smtp->datasend("From: $from\n"); $smtp->datasend("Subject: $subject\n"); $smtp->datasend("Content-type: text/plain\n\n"); # Send the body. $smtp->datasend("$message\n"); $smtp->datasend(" "); my $res = $smtp->dataend(); $smtp->quit; # Close the SMTP connection print "Email was ", $res ? '' : 'un', "successful.\n"; return; }

In reply to Sending email only goes to the local domain ?? by crusty_collins

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.