#!/usr/bin/perl use strict; use warnings; use Net::SMTPS; use CGI::Carp qw(fatalsToBrowser); use English '-no_match_vars'; our @ARGV = ( 'me_at@gmail.com', 'mypassword', 'tosombody@forumsoftware.com', 'me_at@gmail.com' ); my $body = "Test message"; my $headers = "Content-Type: text/plain\r\n\r\n"; my $smtp_server = 'smtp.gmail.com'; my $port = 587; my $ssl = 'starttls'; # 'ssl' / 'starttls' / undef my $mailer = new Net::SMTPS( $smtp_server, Hello => 'host.mydomain.net', Port => $port, Debug => 1, doSSL => $ssl, ) || die "Unable to create Net::SMTPS object. Server: '$smtp_server', port '$port'\n\n" . $OS_ERROR; $mailer->auth($ARGV[0], $ARGV[1]); $mailer->mail($ARGV[3]); $mailer->to($ARGV[2]); $mailer->data(); $mailer->datasend("Subject: SMTP test\r\n\r\n" . $headers . $body); $mailer->dataend; $mailer->quit; print "Content-type: text/html\n\n" or croak 'cannot print line1'; print "Complete"; exit();