ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I am trying to send a message with a perl script using the Net::SMTP::TLS module. I can send it using some SMTP servers, but I cannot get gmail's SMTP to work, or Yahoo's.
I disabled all firewalls. If I use this code:
Code:
1 #!/usr/bin/perl -w
2 use warnings;
3 use strict;
4
5 use Net::SMTP::TLS;
6 my $EMAIL_SMTP='smtp.gmail.com';
7 my $EMAIL_HELLO='smtp.gmail.com';
8 my $EMAIL_PORT=587;
9 my $EMAIL_PASSWORD='password';
10
11 my $mailer = new Net::SMTP::TLS
12 (
13 $EMAIL_SMTP,
14 Hello => $EMAIL_HELLO,
15 Port => $EMAIL_PORT,
16 User => $EMAIL_SENDER,
17 Password=> $EMAIL_PASSWORD,
18 );
19 $mailer->mail('sender@gmail.com');
20 $mailer->to('recepient@gmail.com');
21 $mailer->data;
22 $mailer->datasend("Sent thru TLS!");
23 $mailer->dataend;
24 $mailer->quit;
The script reports:
Quote:
Use of uninitialized value in pattern match (m//) at /usr/local/share/perl/5.8.8/Net/SMTP/TLS.pm line 140, <GEN0> line 7.
Use of uninitialized value in numeric eq (==) at /usr/local/share/perl/5.8.8/Net/SMTP/TLS.pm line 396, <GEN0> line 7.
Use of uninitialized value in concatenation (.) or string at /usr/local/share/perl/5.8.8/Net/SMTP/TLS.pm line 397, <GEN0> line 7.
Use of uninitialized value in concatenation (.) or string at /usr/local/share/perl/5.8.8/Net/SMTP/TLS.pm line 397, <GEN0> line 7.
An error occurred disconnecting from the mail server:
at email.pl line 11
Now, something DOES get sent to my gmail account. But the message shows up in the spam folder, because it has no subject and no message body. All it says in gmail is this:
Quote:
from "sender@gmail.com" <sender@gmail.com>
date Jul 29, 2007 12:55 AM
signed-by gmail.com
mailed-by gmail.com
But there is nothing else. No message body or subject. I would love some help with this. I have confirmed that the module does work, since I can send email through my college account, but I need to be able to use some SMTP server (gmail or yahoo or whatever).
Gmail appears to quit without sending a 221 response
Gmail does support TLS on port 587 as well as SSL.
I am getting the same problem. When Email::Send::SMTP::TLS sends the SMTP QUIT command, Gmail appears to just disconnect rather than sending back a 221 response expected by Email::Send::SMTP::TLS.
I made these two changes below to get it to work.
I don't get the empty message you have, but I note your HELO entry is set to Gmail's address rather than your own hostname.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.