I have now tried using Net::SMTP but only with partial success.
Below is the Perl scritp and the output that I get.
I understand from the output that all should be OK. However the e-mail is not arriving at it to address. I have tried a number of to addresses and even looked in the spam folder when I sent it to myself.
I used the following web sites for help
http://search.cpan.org/~shay/libnet-3.06/lib/Net/SMTP.pm
http://quark.humbug.org.au/publications/perl/perlsmtpintro.html
Can anyone suggest how I can make these e-mails actually arrive and/or find out what is happening to them?
# test e-mail june 2015
use strict;
use warnings;
use Net::SMTP;
use Authen::SASL;
my ($host_em, $to_em, $cc_em, $from_em, $subj_em, $data_em, %attach_em
+, $res_em, $err_em, $smtp);
my ($full_host_name, $password_em, $username);
my ($banner, $domain);
$host_em = 'mail.btinternet.com';
$full_host_name = (gethostbyname $host_em)[0];
print "full_host_name <$full_host_name>\n";
$from_em = 'valid e-mail address';
$cc_em = 'valid e-mail address';
$to_em = 'valid e-mail address';
$password_em = 'password for $from_em';
$subj_em = 'Test e-mail';
$data_em = 'Please let me know if this arrives';
$smtp = Net::SMTP->new($host_em,
Debug => 1);
print "\nsmtp <$smtp>\n";
$smtp->auth ($from_em, $password_em);
print "\nbefore ->mail\n";
$smtp->mail ($from_em);
print "\nbefore ->to\n";
$smtp->to($to_em);
print "\nbefore ->data\n";
$smtp->data;
$smtp->datasend("From: " . $from_em);
$smtp->datasend("To: " . $to_em);
$smtp->datasend('Subject: This is a test');
$smtp->datasend("\n");
$smtp->datasend("$data_em");
$smtp->dataend;
$smtp->quit;
$banner = $smtp->banner;
print "\nbanner <$banner>\n";
$domain = $smtp->domain;
print "\ndomain <$domain>\n";
full_host_name <mail.btinternet.bt.lon5.cpcloud.co.uk>
Net::SMTP>>> Net::SMTP(2.31)
Net::SMTP>>> Net::Cmd(2.29)
Net::SMTP>>> Exporter(5.64_01)
Net::SMTP>>> IO::Socket::INET(1.31)
Net::SMTP>>> IO::Socket(1.31)
Net::SMTP>>> IO::Handle(1.28)
Net::SMTP=GLOB(0x183e988)<<< 220 rgout02.bt.lon5.cpcloud.co.uk ESMTP Service ready
Net::SMTP=GLOB(0x183e988)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0x183e988)<<< 250-rgout02.bt.lon5.cpcloud.co. uk
Net::SMTP=GLOB(0x183e988)<<< 250-DSN
Net::SMTP=GLOB(0x183e988)<<< 250-8BITMIM E
Net::SMTP=GLOB(0x183e988)<<< 250-PIPELINING
Net::SMTP=GLOB(0x183e988)<<< 250-AUTH=LOGIN
Net::SMTP=GLOB(0x183e988)<<< 250-AUTH LOGIN PLAIN
Net::SMTP=GLOB(0x183e988)<<< 250-DELIVERBY 300
Net::SMTP=GLOB(0x183e988)<<< 250 SIZE 41943040
smtp <Net::SMTP=GLOB(0x183e988)>
Net::SMTP=GLOB(0x183e988)>>> AUTH LOGIN
Net::SMTP=GLOB(0x183e988)<<< 334 VXNlcm5hbWU6
Net::SMTP=GLOB(0x183e988)>>> aGVucnkubWVycnl3ZWF0aGVyQGJ0aW50ZXJuZXQuY29t
Net::SMTP=GLOB(0x183e988)<<< 334 UGFzc3dvcmQ6
Net::SMTP=GLOB(0x183e988)>>> Z2VvMTkwMWxlYWNoYQ==
Net::SMTP=GLOB(0x183e988)<<< 235 LOGIN authentication successful
before ->mail
Net::SMTP=GLOB(0x183e988)>>> MAIL FROM:<$from_em>
Net::SMTP=GLOB(0x183e988)<<< 250 MAIL FROM:<$from_em> OK
before ->to
Net::SMTP=GLOB(0x183e988)>>> RCPT TO:<$to_em>
Net::SMTP=GLOB(0x183e988)<<< 250 RCPT TO:<$to_em> OK
before ->data
Net::SMTP=GLOB(0x183e988)>>> DATA
Net::SMTP=GLOB(0x183e988)<<< 354 Start mail input; end with <CRLF>.<CRLF>
Net::SMTP=GLOB(0x183e988)>>> From: $from_em
Net::SMTP=GLOB(0x183e988)>>> To: $to_em
Net::SMTP=GLOB(0x183e988)>>> Subject: This is a test
Net::SMTP=GLOB(0x183e988)>>> Please let me know if this arrives
Net::SMTP=GLOB(0x183e988)>>> .
Net::SMTP=GLOB(0x183e988)<<< 250 <556D7AAA00016CE0> Mail accepted
Net::SMTP=GLOB(0x183e988)>>> QUIT
Net::SMTP=GLOB(0x183e988)<<< 221 rgout02.bt.lon5.cpcloud.co.uk QUIT
banner <rgout02.bt.lon5.cpcloud.co.uk ESMTP Service ready
>
domain <rgout02.bt.lon5.cpcloud.co.uk>
|