Wednesday, November 28, 2007

Email::Send::SMTP::TLS

I wrote a new CPAN module Email::Send::SMTP::TLS.
it can use Gmail smtp.gmail.com to send email, and it runs well under Win32.

I tried Email::Send::Gmail, but it's not working in my computer at all.

example:

use Email::Send;

my $mailer = Email::Send->new( {
mailer => 'SMTP::TLS',
mailer_args => [
Host => 'smtp.gmail.com',
Port => 587,
User => 'username@gmail.com',
Password => 'password',
Hello => 'fayland.org',
]
} );

use Email::Simple::Creator; # or other Email::
my $email = Email::Simple->create(
header => [
From => 'username@gmail.com',
To => 'to@mail.com',
Subject => 'Subject title',
],
body => 'Content.',
);

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

Labels:

Sunday, August 20, 2006

GMail and Email::Send

I use GMail in my daily life. and the GMail SMTP is using TSL

The Email::Send seems not to support TSL. and Catalyst::Plugin::Email is using Email::Send.

Updated

I haven't noticed until today that Ricardo SIGNES has applied this patch as Email::Send 2.180.
So I removed the link in fayland.googlecode.
------------------------

so I create a patch to Email::Send::SMTP. http://fayland.googlecode.com/svn/trunk/MISC/patches/EMail_Send_SMTP.patch
but the module Net::SMTP::TLS breaks some function of Net::SMTP (like don't return a true value of ->mail, ->to only support one scalar and no param, etc.)
I sent the patch to the author of Email::Send, but I'm not sure whether he will accept it because of the Net::SMTP::TLS.

the yml config of Catalyst::Plugin::Email should something like
email:
- SMTP
- smtp.gmail.com
- tls
- 1
- Hello
- 'www.fayland.org'
- Port
- 587
- User
- 'yourname@gmail.com'
- Password
- yourpassword
and
$c->email(
header => [
From => 'yourname@gmail.com',
To => 'tosomewhere@somemailhost.com',
Subject => 'Test Foorum Email'
],
body => 'OK',
);


Have fun!

Labels: