CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Send Mail from Hotmail SMTP

 



Adamba
Novice

Jun 16, 2010, 11:38 AM

Post #1 of 11 (2409 views)
Send Mail from Hotmail SMTP Can't Post

Hey,

i'm trying to make a script that sends an email from Hotmail to any other email account. I dunno why, but it doesn't work... can anyone check out why...? I think the problem is maybe with the port or the starttls security that (I think) microsoft uses...
Should I use some other module?

(Sorry for my english...)


Code
 #!/usr/bin/perl 
use strict;
use warnings;
use Email::Send;
use Email::Simple::Creator;

my $Hotmail = Email::Simple->create(
header => [
From => 'you@hotmail.com',
To => 'someone@gmail.com',
Subject => 'Test Hotmail',
],
body => 'The server is down. Start panicing.',
);

my $sender1 = Email::Send->new(
{ mailer => 'SMTP',
mailer_args => [
Host => 'smtp.live.com:25',
ssl => 1,
username => 'username@hotmail.com',
password => 'password',
]
}
);

eval { $sender1->send($Hotmail) };
die "Error sending email: $@" if $@;



Bianca
User

Jun 16, 2010, 11:24 PM

Post #2 of 11 (2398 views)
Re: [Adamba] Send Mail from Hotmail SMTP [In reply to] Can't Post

What means "it doesn't work". Please descripe it. Error's?


Adamba
Novice

Jun 16, 2010, 11:59 PM

Post #3 of 11 (2395 views)
Re: [Bianca] Send Mail from Hotmail SMTP [In reply to] Can't Post

I don't get an error... I just doesn't get the email....


Bianca
User

Jun 17, 2010, 12:22 AM

Post #4 of 11 (2392 views)
Re: [Adamba] Send Mail from Hotmail SMTP [In reply to] Can't Post

Can you test it with Net::SMTP?


rovf
Veteran

Jun 17, 2010, 4:26 AM

Post #5 of 11 (2388 views)
Re: [Adamba] Send Mail from Hotmail SMTP [In reply to] Can't Post

You don't evaluate the return value of send().

But did you notice, what CPAN says about Email::Send:

Email::Send is going away [..]. It has API design problems that make it hard to usefully extend


Adamba
Novice

Jun 17, 2010, 7:31 AM

Post #6 of 11 (2381 views)
Re: [rovf] Send Mail from Hotmail SMTP [In reply to] Can't Post

Is there any other module that I can use?


Bianca
User

Jun 17, 2010, 8:04 AM

Post #7 of 11 (2377 views)
Re: [Adamba] Send Mail from Hotmail SMTP [In reply to] Can't Post

yes, use MIME::Lite to build the mail and Net::SMTP to send it.


rovf
Veteran

Jun 18, 2010, 12:23 AM

Post #8 of 11 (2363 views)
Re: [Adamba] Send Mail from Hotmail SMTP [In reply to] Can't Post

I'm using Mail::SendEasy.

Also, if you read the documentation of Email::Send on CPAN, you will see that the author recommend to use their own successor module. If I remember right, it was Email::Sender, but better you have a look by yourself.


Adamba
Novice

Jun 18, 2010, 12:43 AM

Post #9 of 11 (2362 views)
Re: [rovf] Send Mail from Hotmail SMTP [In reply to] Can't Post

I just read it too...
I"ll try using Email::Sender
Thanks! :)


Adamba
Novice

Jun 19, 2010, 5:02 AM

Post #10 of 11 (2341 views)
Re: [Adamba] Send Mail from Hotmail SMTP [In reply to] Can't Post

I've tried using Net::SMTP::TLS to send from hotmail, but now I'm getting a connection timed out error...

Anyone?



Code
use strict; 
use warnings;
use Email::Simple;
use Net::SMTP::SSL;
use Net::SMTP::TLS;

my $to = 'someone@example.com';
my $msg = "Test";
my $from = 'username@hotmail.com>';
my $subject = 'Test Hotmail';

my $Hotmail = new Net::SMTP::TLS( 'localhost',
Hello => 'smtp.live.com',
Port => 25,
Debug => 1,
User => 'username@hotmail.com',
Password=> 'password'
);

$Hotmail->mail($from);
$Hotmail->to($to);
$Hotmail->data();
$Hotmail->datasend("From: " . $from . "\n");
$Hotmail->datasend("To: " . $to . "\n");
$Hotmail->datasend("Subject: " . $subject . "\n");
$Hotmail->datasend("\n");
$Hotmail->datasend($msg . "\n");
$Hotmail->dataend();
$Hotmail->quit;



hoahongdenH
New User

Jun 21, 2010, 7:14 PM

Post #11 of 11 (2306 views)
Re: [Adamba] Send Mail from Hotmail SMTP [In reply to] Can't Post

I try up with postfix and send mail to: gmail from localhost with Net::SMTP successfull.
but when I try send to localhost from gmail -> fail.
#!/usr/bin/perl -w
use strict;
use warnings;
use Email::Simple;
use Net::SMTP;

my $to = 'hoahongdenH@gmail.com';
my $msg = "Test";
my $from = 'root@localhost>';
my $subject = 'Test Gmail';

my $Hotmail = new Net::SMTP('localhost',
Hello => 'smtp.gmail.com',
Port => 25,
Debug => 1,
User => 'root@localhost',
Password=> 'pass+_'
);

$Hotmail->mail($from);
$Hotmail->to($to);
$Hotmail->data();
$Hotmail->datasend("From: " . $from . "\n");
$Hotmail->datasend("To: " . $to . "\n");
$Hotmail->datasend("Subject: " . $subject . "\n");
$Hotmail->datasend("\n");
$Hotmail->datasend($msg . "\n");
$Hotmail->dataend();
$Hotmail->quit;


(This post was edited by hoahongdenH on Jun 21, 2010, 7:15 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives