In an older episode, on 2011-08-21 16:03, Roger Goh wrote:
how do I sent an alert email to notify support if outgoing mail is not working anymore?
For such cases, I use a perl script that connects to a different SMTP server to send a mail. See attachment.
Hope this helps, wolfgang
#!/usr/bin/perl # -w # wolfgang.zei...@desy.de # send an email containing STDIN from $ARGV[0] to $ARGV[1] # via SMTP to 127.0.0.1 port 25 # $ARGV[0] can be '<>' to prevent bounces, # STDIN should then contain a From: header line use Net::SMTP; # qw(smtp); my $sender = $ARGV[0]; shift @ARGV; my $recipient = $ARGV[0]; shift @ARGV; my $recipient2 = $ARGV[0]; shift @ARGV; undef $/; my $text = <>; #exit; my $mailer = Net::SMTP->new("other.smtp.server:25") or die $@; $mailer->mail("$sender"); $mailer->to ("$recipient"); $mailer->to ("$recipient2"); $mailer->data(); $mailer->datasend("$text"); $mailer->dataend(); $mailer->quit or die "mail sending failure";