nervousmark has asked for the wisdom of the Perl Monks concerning the following question:
my $from = 'email@gmail.com'; my $to = 'email@email.com'; my $Subject = 'subj'; my $filepath = 'c:\programming'; my $txttype = 'text/plain'; my $filenm = 'txt.txt'; my $user = 'username'; #confused if I need to use my email address as +username or just username my $passwd = 'pass'; #--------- NET::SMTP::SERVER ---------- my $smtp = Net::SMTP::Server->new( Host => 'smtp.gmail.com', Hello => 'smtp.gmail.com', Timeout => 30, Debug => 1, Auth => ($user, $passwd), ); $smtp->mail("email\@gmail.com"); $smtp->recipient("email\@gmail.com", \ "email\@email.com"); $smtp->datasend("From: email\@gmail.com"); $smtp->datasend("To: email\@email.com"); $smtp->datasend("Subject: This is a test"); $smtp->datasend("\n"); $smtp->datasend("blahblah"); $smtp->dataend; $smtp->quit; # This resulted in an error that the program wsa unable to connect to +gmail #------------ MAIL::WEBMAIL::GMAIL -------- my $gmail = Mail::Webmail::Gmail->new( username => $user, password => +$passwd ); $gmail->send_message( to => $to, subject => 'Test Message', msgbody => + 'This is a test.' ); # This completed without error, but I never recieved an email #------------ MAIL::SENDER ----------------- my $sender=Mail::Sender->new; if ($sender->MailMsg({ smtp => 'smtp.gmail.com', from => 'email@gmail.com', to => 'email@email.com', subject => 'test email', msg => 'testing email', auth => 'LOGIN', authid => $user, authpwd => $passwd, }) < 0) { die "$Mail::Sender::Error\n"; } print "Mail sent OK."; # This was not able to connect either #------------ MIME::LITE -------------------- my $msg = MIME::Lite->new( From => $from, To => $to, Subject => $Subject, Data => "Blah blah" #smtp => 'smtp.gmail.com' ); $msg->attr("content-type" => "multipart/mixed"); #for each attachment: $msg->attach( Type => "text/plain", Path => $filepath, Filename => $filenm, Disposition => "attachment" ); MIME::Lite->send('smtp','smtp.gmail.com', Port => '465',Debug => '1', +Hello => 'gmail.com' , User=>$user, Password =>$passwd, Timeout => 60 +); $msg->send(); # This resulted in not being able to connect to gmail either
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: What is the easiest/most efficient way to send an email w/ attachment through gmail
by marto (Cardinal) on Jul 18, 2010 at 09:28 UTC | |
|
Re: What is the easiest/most efficient way to send an email w/ attachment through gmail
by sflitman (Hermit) on Jul 18, 2010 at 04:10 UTC | |
|
Re: What is the easiest/most efficient way to send an email w/ attachment through gmail
by sierpinski (Chaplain) on Jul 18, 2010 at 05:26 UTC | |
|
Re: What is the easiest/most efficient way to send an email w/ attachment through gmail
by aquarium (Curate) on Jul 18, 2010 at 23:43 UTC | |
by Anonymous Monk on Jul 19, 2010 at 01:48 UTC | |
by aquarium (Curate) on Jul 19, 2010 at 23:57 UTC |