0
votes

Whenever I run a simple send email function using Email::Send::Gmail I get this error:

[Mon Jan 28 11:37:57 2013] [error] [client 31.171.245.] Error sending email: Email::Send::Gmail: error connecting to server smtp.gmail.com at /usr/local/share/perl5/Email/Send.pm line 252, referer: http://**.cgi

However, exact same code is working when run from command line. And smtp.gmail.com is available when telneting from command line. It this because of the persistence or am I missing something?

2
Perhaps GMail has specifically disallowed sending emails via script?user1919238
Also, perhaps this thread will help: perlmonks.org/?node_id=719444user1919238
Well it is working from the command line, I can't see any reason why the same code shouldn't work as CGIBogdan

2 Answers

0
votes

Alrgiht, I got it. Seems selinux on CentOS was blocking outside connections from httpd, thus the script was not connecting.

You need to enter this

setsebool -P httpd_can_network_connect=1

In order to connect.

-1
votes

Try (in your cgi script) doing this:

use Net::SMTP::SSL;
Net::SMTP::SSL->new( 'smtp.gmail.com', Port => 465, Debug => 1 );

and see if the debugging information tells you anything helpful.

Is it possible that your cgi script is using a different perl, with different modules installed?