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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |