Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Mail::Sender with SSL

971 views
Skip to first unread message

Thomas Dean

unread,
Aug 7, 2012, 1:38:57 PM8/7/12
to begi...@perl.org
Hi there,

I have succeeded in sending mail to my SMTP server with Mail::Sender
without SSL. But now I'm wondering how to do that with SSL, for example,
GMail. After reading the doc, I set TLS_required to 1 when I'm calling
Mail::Sender->new, but nohing works. I tried to debug the program but
found nothing different whether I turn TLS_required on or not.

So how can I send mail with SSL?

BTW, I cannot sill tell SSL from TLS.

Thomas

Jeff Pang

unread,
Aug 7, 2012, 5:53:30 AM8/7/12
to begi...@perl.org
use MIME::Lite;
use MIME::Words qw(encode_mimewords);
use Net::SMTP::SSL;
BEGIN { @MIME::Lite::SMTP::ISA = qw(Net::SMTP::SSL); }

The others are almost the same as MIME::Lite.

--
http://liren188.taobao.com/

Chris Nehren

unread,
Aug 7, 2012, 10:05:26 AM8/7/12
to begi...@perl.org
On Tue, Aug 07, 2012 at 17:38:57 +0000 , Thomas Dean wrote:
> Hi there,
>
> I have succeeded in sending mail to my SMTP server with Mail::Sender
> without SSL. But now I'm wondering how to do that with SSL, for example,
> GMail. After reading the doc, I set TLS_required to 1 when I'm calling
> Mail::Sender->new, but nohing works. I tried to debug the program but
> found nothing different whether I turn TLS_required on or not.

You should look at Email::Sender::SMTP::TLS instead--it's the de facto,
mature way of sending email through TLS SMTP servers with perl, and is
actively supported. Mail::Sender reinvents a lot of wheels, poorly, as
you are finding.

Also avoid the MIME::Lite suggestion posted, as that module is
deprecated and not recommended for new code due to the vagaries and odd
bugs in it--also due to the fact that it's not actively maintained or
developed any more and just receives an occasional bug fix.

--
Chris Nehren | Coder, Sysadmin, Masochist
Shadowcat Systems Ltd. | http://shadowcat.co.uk/

Thomas Dean

unread,
Aug 8, 2012, 10:31:25 AM8/8/12
to Chris Nehren, begi...@perl.org
Great, thanks.

Thomas


Jeff Pang

unread,
Aug 8, 2012, 2:34:43 AM8/8/12
to begi...@perl.org

> Also avoid the MIME::Lite suggestion posted, as that module is
> deprecated and not recommended for new code due to the vagaries and odd
> bugs in it--also due to the fact that it's not actively maintained or
> developed any more and just receives an occasional bug fix.

what's the better module to handle MIME in today time? thanks.

--
http://liren188.taobao.com/

Jenda Krynicky

unread,
Aug 15, 2012, 6:05:56 PM8/15/12
to begi...@perl.org
From: Chris Nehren <c.nehren/begi...@shadowcat.co.uk>
> On Tue, Aug 07, 2012 at 17:38:57 +0000 , Thomas Dean wrote:
> > Hi there,
> >
> > I have succeeded in sending mail to my SMTP server with Mail::Sender
> > without SSL. But now I'm wondering how to do that with SSL, for example,
> > GMail. After reading the doc, I set TLS_required to 1 when I'm calling
> > Mail::Sender->new, but nohing works. I tried to debug the program but
> > found nothing different whether I turn TLS_required on or not.
>
> You should look at Email::Sender::SMTP::TLS instead--it's the de facto,
> mature way of sending email through TLS SMTP servers with perl, and is
> actively supported. Mail::Sender reinvents a lot of wheels, poorly, as
> you are finding.

It reinvented a lot of wheels that were not available at the time it
was written. The fact that there is a specific module now doesn't
mean it had been available or working under the target operating
systems always.

Enough plesantries, Tom, what exactly did you try an how exactly did
it fail?

Jenda


===== Je...@Krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery

Chris Nehren

unread,
Aug 15, 2012, 6:55:30 PM8/15/12
to begi...@perl.org
On Thu, Aug 16, 2012 at 00:05:56 +0200 , Jenda Krynicky wrote:
> From: Chris Nehren <c.nehren/begi...@shadowcat.co.uk>
> > On Tue, Aug 07, 2012 at 17:38:57 +0000 , Thomas Dean wrote:
> > > Hi there,
> > >
> > > I have succeeded in sending mail to my SMTP server with Mail::Sender
> > > without SSL. But now I'm wondering how to do that with SSL, for example,
> > > GMail. After reading the doc, I set TLS_required to 1 when I'm calling
> > > Mail::Sender->new, but nohing works. I tried to debug the program but
> > > found nothing different whether I turn TLS_required on or not.
> >
> > You should look at Email::Sender::SMTP::TLS instead--it's the de facto,
> > mature way of sending email through TLS SMTP servers with perl, and is
> > actively supported. Mail::Sender reinvents a lot of wheels, poorly, as
> > you are finding.
>
> It reinvented a lot of wheels that were not available at the time it
> was written. The fact that there is a specific module now doesn't
> mean it had been available or working under the target operating
> systems always.

Email::Sender is still the right tool to use, and actually works. It
probably sends more mail in a day than you ever will*. As for
your spurious "working under the target operating system always" claim,
Email::Sender::Transport::SMTP::TLS has a flawless CPAN testers report
card, visible here:
http://www.cpantesters.org/distro/E/Email-Sender-Transport-SMTP-TLS.html#Email-Sender-Transport-SMTP-TLS-0.10
The SYNOPSIS provides all (or very nearly all) the code Thomas needs,
with very little tweaking besides configuration. How can it possibly be
easier?

This "use the old, bad tool because it's what the OP started with"
approach leads only to pain and suffering.


* having put it into production at a large ESP that handles thousands of
per day, I'm pretty sure this is the case.

Jenda Krynicky

unread,
Aug 16, 2012, 12:30:10 PM8/16/12
to begi...@perl.org
From: Chris Nehren <c.nehren/begi...@shadowcat.co.uk>
> On Thu, Aug 16, 2012 at 00:05:56 +0200 , Jenda Krynicky wrote:
> > From: Chris Nehren <c.nehren/begi...@shadowcat.co.uk>
> > > On Tue, Aug 07, 2012 at 17:38:57 +0000 , Thomas Dean wrote:
> > > > Hi there,
> > > >
> > > > I have succeeded in sending mail to my SMTP server with Mail::Sender
> > > > without SSL. But now I'm wondering how to do that with SSL, for example,
> > > > GMail. After reading the doc, I set TLS_required to 1 when I'm calling
> > > > Mail::Sender->new, but nohing works. I tried to debug the program but
> > > > found nothing different whether I turn TLS_required on or not.
> > >
> > > You should look at Email::Sender::SMTP::TLS instead--it's the de facto,
> > > mature way of sending email through TLS SMTP servers with perl, and is
> > > actively supported. Mail::Sender reinvents a lot of wheels, poorly, as
> > > you are finding.
> >
> > It reinvented a lot of wheels that were not available at the time it
> > was written. The fact that there is a specific module now doesn't
> > mean it had been available or working under the target operating
> > systems always.
>
> Email::Sender is still the right tool to use, and actually works. It
> probably sends more mail in a day than you ever will*.

Having been the basis of the Hotmail service Mail::Sender sent more
mail you ever will. By order of several magnitudes. Not sure what
they use now, but they had been using Mail::Sender for several years
as could have be seen in the mail headers. Several other similar
services used or use the same module.

> As for
> your spurious "working under the target operating system always" claim,
> Email::Sender::Transport::SMTP::TLS has a flawless CPAN testers report
> card, visible here:
> http://www.cpantesters.org/distro/E/Email-Sender-Transport-SMTP-TLS.html#Email-Sender-Transport-SMTP-TLS-0.10

I can uninvent the wheels I had to invent back in the day because no
wheels had been available back then or those that were available did
not work under operating systems I had to support.

The first version of Email::Sender was released 2008-12-10, the first
version of Mail::Sender was released sometime in 1998! That's ten
years of CPAN growth!

> The SYNOPSIS provides all (or very nearly all) the code Thomas needs,
> with very little tweaking besides configuration. How can it possibly be
> easier?
>
> This "use the old, bad tool because it's what the OP started with"
> approach leads only to pain and suffering.
>
>
> * having put it into production at a large ESP that handles thousands of
> per day, I'm pretty sure this is the case.

I'm incredibly impressed ...
0 new messages