use strict; use Net::SMTP; my $from = 'somebody@gmail.com'; my $full_name = "Some Body"; my $pw = "my_password"; my $to = 'someone@somewhere.com'; my $smtp = Net::SMTP->new('smtp.gmail.com', Port=> 587, User => $from, Password => $pw ); $smtp->mail($from); $smtp->recipient($to); $smtp->data(); $smtp->datasend("To: $to"); $smtp->datasend("From: $full_name\n"); $smtp->datasend("Content-Type: text/plain \n"); $smtp->datasend("Subject: A Test Mail"); $smtp->datasend("\n"); $smtp->datasend("This is a test mail body"); $smtp->datasend("\n"); $smtp->dataend(); $smtp->quit();