#!/usr/bin/perl use strict; use warnings; use IO::Socket::SSL qw(debug3); use Net::SMTP; use CGI::Carp qw(fatalsToBrowser); use English '-no_match_vars'; our @ARGV = ( 'mygmail@gmail.com', 'mypassword', 'touser@forumsoftware +.com', 'mygmail@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 $mailer = new Net::SMTP( $smtp_server, Hello => 'host.domain.net', Port => $port, Debug => 1, User => $ARGV[0], Password => $ARGV[1], ) || die "Unable to create Net::SMTP 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: Net::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(); #### Net::SMTP>>> Net::SMTP(2.31) Net::SMTP>>> Net::Cmd(2.29) Net::SMTP>>> Exporter(5.58) Net::SMTP>>> IO::Socket::INET(1.29) Net::SMTP>>> IO::Socket(1.29) Net::SMTP>>> IO::Handle(1.25) Net::SMTP=GLOB(0x97fc844)<<< 220 smtp.gmail.com ESMTP 89sm4313614pfi.2 - gsmtp Net::SMTP=GLOB(0x97fc844)>>> EHLO host.domain.net Net::SMTP=GLOB(0x97fc844)<<< 250-smtp.gmail.com at your service, [67.222.16.122] Net::SMTP=GLOB(0x97fc844)<<< 250-SIZE 35882577 Net::SMTP=GLOB(0x97fc844)<<< 250-8BITMIME Net::SMTP=GLOB(0x97fc844)<<< 250-STARTTLS Net::SMTP=GLOB(0x97fc844)<<< 250-ENHANCEDSTATUSCODES Net::SMTP=GLOB(0x97fc844)<<< 250-PIPELINING Net::SMTP=GLOB(0x97fc844)<<< 250-CHUNKING Net::SMTP=GLOB(0x97fc844)<<< 250 SMTPUTF8 Net::SMTP=GLOB(0x97fc844)>>> MAIL FROM: Net::SMTP=GLOB(0x97fc844)<<< 530 5.7.0 Must issue a STARTTLS command first. 89sm4313614pfi.2 - gsmtp