All pastes #80536 Raw Edit

Untitled

public text v1 · immutable
·published 2006-07-06 14:43 UTC
rendered paste body
#!/usr/bin/perl -w

# unattended Mail::Sendmail test, sends a message to the author
# but you probably want to change $mail{To} below
# to send the message to yourself.
# version 0.78

# if you change your mail server, you may need to change the From:
# address below.
$mail{From} = 'My name <blah@email.com>';

$mail{To}   = 'My name <blah@email.com>';
#$mail{To}   = 'Sendmail Test <sendmail@alma.ch>, You me@myaddress';

# if you want to get a copy of the test mail, you need to specify your
# own server here, by name or IP address
$server = 'mail03.safersys.org';
#$server = 'my.usual.mail.server';

BEGIN { $| = 1; print "1..2\n"; }
END {print "not ok 1\n" unless $loaded;}

print <<EOT
Test Mail::Sendmail $Mail::Sendmail::VERSION

Current recipient(s): '$mail{To}'

EOT
;

use Mail::Sendmail;

$loaded = 1;
print "ok 1\n";

if ($server) {
    $mail{Smtp} = $server;
    print "Server set to: $server\n";
}

# starting the message body

$file = '/export/home/blah/apps/Mail-Sendmail/message.txt';
open (MESSAGE, $file) || die ("Could not open file <br> $!");
my @lines;
@lines = <MESSAGE>;
close (MESSAGE);
print @lines;


$mail{Subject} = "Mail::Sendmail version $Mail::Sendmail::VERSION test";

#$mail{Message} = "This is a test message sent with Perl version $] from a $^O system.\n\n";
#$mail{Message} .= "It contains an accented letter: à (a grave).\n";
#$mail{Message} .= "It was sent on " . Mail::Sendmail::time_to_date() . "\n";

$mail{Message} = @lines;



# Go send it
print "Sending...\n";

if (sendmail %mail) {
    print "content of \$Mail::Sendmail::log:\n$Mail::Sendmail::log\n";
    if ($Mail::Sendmail::error) {
        print "content of \$Mail::Sendmail::error:\n$Mail::Sendmail::error\n";
    }
    print "ok 2\n";
}
else {
    print "\n!Error sending mail:\n$Mail::Sendmail::error\n";
    print "not ok 2\n";
}