chicago928 has asked for the wisdom of the Perl Monks concerning the following question:

Hello. I would like to be able to send emails from perl scripts from my gmail account. I know that somehow I probably need to submit my gmail name/password but I don't know where that goes at all even after looking at the Net::SMTP man. The following is the code that I have

use Net::SMTP; my $ServerName = "smtp.google.com" ; my $smtp = Net::SMTP->new($ServerName, port=> 587, Debug => 1) ; die "Couldn't connect to server" unless $smtp ; my $MailFrom = "sender\@gmail.com" ; my $MailTo = "receiver\@received.com" ; $smtp->mail( $MailFrom ) ; $smtp->to( $MailTo ) ; $smtp->data() ; $smtp->datasend("Hello World!\n\n") ; $smtp->dataend() ; $smtp->quit() ;

The debugs I received include 550 5.7.1 ... Relaying denied and 503 need recipient

Thanks

Replies are listed 'Best First'.
Re: sending emails with gmail
by hubb0r (Pilgrim) on Jul 26, 2005 at 17:41 UTC
    You'll probably have much better luck using this module: Mail::Webmail::Gmail
    It has a fully featured interface to gmail, inclusive of sending and receiving mail.
    use Mail::Webmail::Gmail; my $gmail = Mail::Webmail::Gmail->new( username => 'username', password => password', ); $gmail->send_message( to => 'user@domain.com', subject => Test Message +', msgbody => 'This is a test.' );
Re: sending emails with gmail
by ikegami (Patriarch) on Jul 26, 2005 at 17:48 UTC

    Gmail uses a secure version of SMTP. Some ideas for accessing Gmail were posted earlier.

    Update: The OP edited his post. It originally mentioned the server was expecting a "STARTTLS" command.

Re: sending emails with gmail
by b10m (Vicar) on Jul 26, 2005 at 17:48 UTC

    You probably like Net::ESMTP better in this case:

    Net::ESMTP is a wrapper for SMTP client library libESMTP (written in C). It has clear interface and access to SMTP advanced features like: SASL (authorization), TLS (privacy and authentication), ETRN, DSN etc.

    PS: It's nice if you do not change your node. If you want to add/change something, let people know ;)

    --
    b10m

    All code is usually tested, but rarely trusted.