Log In

Step 1

Please make sure that you have installed MIME::Entity, Net::SMTP_auth and Net::SMTP perl modules.

Step 2

Please change the following variables in this script:

  • from: the sender’s email address.
  • to: the recipient’s email address.
  • username: your SMTP username.
  • password: your SMTP password.
#!/usr/bin/perl

use MIME::Entity;
use Net::SMTP;
use Net::SMTP_auth;

my $from = 'sender@example.com';
my $to = 'recipient@example.com';
my $subject = 'Your Subject';
my $text_message = "It is a text message n";
my $html_message = "It is a html message";

my $message = MIME::Entity->build (
Type => 'multipart/alternative',
From => $from,
To => $to,
Subject => $subject
);

$message->attach(Type => 'text/plain', Data => $text_message);
$message->attach(Type => 'text/html', Data => $html_message);

my $username = 'USERNAME';
my $password = 'PASSWORD';
my $smtp;

if (not $smtp = Net::SMTP->new('mail.smtp2go.com',
Port => 2525, # 8025, 587 and 25 can also be used.
Timeout => 30)) {
die "Could not connect to servern";
}

$smtp->auth($username, $password) || die "Authentication failed! n";
$smtp->mail($from);
$smtp->to($to);
$smtp->data($message->as_string);
$smtp->quit;

Ready for better email delivery?

Try SMTP2GO free for as long as you like:

Try SMTP2GO Free → Paid plans available for over 1,000 emails/month.