use strict; use warnings; use Email::Send::SMTP::Gmail; my ($mail,$error)=Email::Send::SMTP::Gmail->new( -smtp=>'smtp.gmail.com', -login=>'whateveraddress@gmail.com', -pass=>'whatever_pass'); print "session error: $error" unless ($email!=-1); $mail->send(-to=>'target@xxx.com', -subject=>'Hello!', -body=>'Just testing it', -attachments=>'full_path_to_file'); $mail->bye;