Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Sending email via Gmail

by Gangabass (Priest)
on Jul 22, 2011 at 16:42 UTC ( #916163=perlquestion: print w/ replies, xml ) Need Help??
Gangabass has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Monks. I have email sending code which doesn't work without any error messages (by "doesn't work" i mean all seams OK but i have no message in my mail box):
use strict; use warnings; use Email::Send; use Email::Simple::Creator; report_update(); sub report_update { my $mailer = Email::Send->new( { mailer => 'SMTP::TLS', mailer_args => [ Host => 'smtp.gmail.com', Port => 587, User => $CONFIG{EMAIL_USER}, Password => $CONFIG{EMAIL_PASS}, Hello => 'localhost', ] } ); my $email = Email::Simple->create( header => [ From => $CONFIG{EMAIL_USER}, To => $CONFIG{TARGET_EMAIL}, Subject => 'Updated info finded!', ], body => 'Updated info finded!', ); eval { $mailer->send($email) }; die "Error sending email: $@" if $@; print "Finished!\n"; }
Could you give me a hint what's wrong with it? UpdateThanks all for the answers. Now i'm using Email::Send::Gmail and the problem is solved. But the question is still in my head: why this code don't work on one of my machine and works on another?

Comment on Sending email via Gmail
Download Code
Re: Sending email via Gmail
by afoken (Parson) on Jul 22, 2011 at 16:56 UTC

    Without further debugging: When you talk to smtp.gmail.com, don't pretend to be "localhost", i.e. smtp.gmail.com. Use your real hostname. If you don't know it, use DNS to find it, or use your external IP address.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      You're right, using "localhost" is a bad idea but i'm sure this is not an issue here because same code is working on another machine.
Re: Sending email via Gmail
by wind (Priest) on Jul 22, 2011 at 17:06 UTC
Re: Sending email via Gmail
by zentara (Archbishop) on Jul 22, 2011 at 17:12 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://916163]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (11)
As of 2014-12-27 21:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls