I am sending email with Perl through Gmail with the help of Email::Send::SMTP::Gmail. The script is stored as send.pl. I am accesing it throgh localhost/send.pl. I have to type in my password to my Gmail account in this Perl script and then access it from my browser.
Is there any way that anyone browsing to this site can obtain my Gmail password?
My code:
use strict;
use warnings;
use Email::Send::SMTP::Gmail;
my $mail = Email::Send::SMTP::Gmail->new(
-smtp => 'gmail.com',
-login => 'whateveraddress@gmail.com',
-pass => 'whatever_pass'
);
$mail->send(
-to => 'target@xxx.com',
-subject => 'Hello!',
-charset => 'KOI8-R',
-verbose => '1',
-body => 'Just testing it',
-attachments => 'full_path_to_file'
);
$mail->bye;
So long as the server remains properly configured, no, your password is safe.
It is, however, a good idea to keep the password in a configuration file outside of the site root and read it from your script rather then embedding it in the script itself. That way, if the server configuration is changed and starts serving up the script raw instead of executing it, your password is still safe.