Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Recommendation for email sending modules please

by duelafn (Priest)
on Sep 10, 2011 at 19:33 UTC ( #925273=note: print w/ replies, xml ) Need Help??


in reply to Recommendation for email sending modules please

Plain Text Emails:

use Email::Simple; use Email::Sender::Simple qw(sendmail); my $email = Email::Simple->create( header => [ From => "", To => "", Subject => "" ], body => $message, ); sendmail($email);

HTML Emails (MIME::Lite::HTML will handle attaching images, css, ...):

use MIME::Lite; use MIME::Lite::HTML; use HTML::FormatText::WithLinks; Send( { From => "", To => "", Subject => "" }, $html_message ); sub Send { state $mk_text = HTML::FormatText::WithLinks->new(); my ($opt, $html, $text) = @_; $text ||= $mk_text->parse($html); my $ml = MIME::Lite::HTML->new( TextCharset => 'UTF-8', TextEncoding => 'base64', HTMLCharset => 'UTF-8', %$opt, ); my $m = $ml->parse($html,$text); my @errors; die "@errors" if @errors = $ml->errstr; $m->send; }

Good Day,
    Dean


Comment on Re: Recommendation for email sending modules please
Select or Download Code
Re^2: Recommendation for email sending modules please
by palkia (Scribe) on Sep 16, 2011 at 02:41 UTC
    Thx
    I tried the 1st example but it didn't work from some reason.
    Please tell me what I'm doing wrong.
    use Email::Simple; use Email::Sender::Simple qw(sendmail); my $email = Email::Simple->create( header => [ From => 'a real email', To => 'my real email', Subject = +> "zzz" ], body => 'it work !', #no it's not ); sendmail($email);
    But it died saying
    unable to establish SMTP connection Trace begun at C:\strawberry\perl\site\lib\Email\Sender\Transport\SMTP +.pm line 9 5 Email::Sender::Transport::SMTP::_throw('Email::Sender::Transport::SMTP +=HASH(0x14 c7b04)', 'unable to establish SMTP connection') called at C:\strawberr +y\perl\sit e\lib\Email\Sender\Transport\SMTP.pm line 62 Email::Sender::Transport::SMTP::_smtp_client('Email::Sender::Transport +::SMTP=HAS H(0x14c7b04)') called at C:\strawberry\perl\site\lib\Email\Sender\Tran +sport\SMTP .pm line 104 Email::Sender::Transport::SMTP::send_email('Email::Sender::Transport:: +SMTP=HASH( 0x14c7b04)', 'Email::Abstract=ARRAY(0x38b1c)', 'HASH(0x12012a4)') call +ed at C:\s trawberry\perl\site\lib\Email\Sender\Role\CommonSending.pm line 27 Email::Sender::Role::CommonSending::__ANON__ at C:\strawberry\perl\sit +e\lib\Try\ Tiny.pm line 76 eval {...} at C:\strawberry\perl\site\lib\Try\Tiny.pm line 67 Try::Tiny::try('CODE(0x1545c44)', 'Try::Tiny::Catch=REF(0x1541a64)') c +alled at C :\strawberry\perl\site\lib\Email\Sender\Role\CommonSending.pm line 37 Email::Sender::Role::CommonSending::send('Email::Sender::Transport::SM +TP=HASH(0x 14c7b04)', 'Email::Abstract=ARRAY(0x38b1c)', 'HASH(0x14c8414)') called + at C:\str awberry\perl\site\lib\Email\Sender\Simple.pm line 110 Email::Sender::Simple::send_email('Email::Sender::Simple', 'Email::Abs +tract=ARRA Y(0x38b1c)', 'HASH(0x1201334)') called at C:\strawberry\perl\site\lib\ +Email\Send er\Role\CommonSending.pm line 27 Email::Sender::Role::CommonSending::__ANON__ at C:\strawberry\perl\sit +e\lib\Try\ Tiny.pm line 76 eval {...} at C:\strawberry\perl\site\lib\Try\Tiny.pm line 67 Try::Tiny::try('CODE(0xd0a83c)', 'Try::Tiny::Catch=REF(0x1283bdc)') ca +lled at C: \strawberry\perl\site\lib\Email\Sender\Role\CommonSending.pm line 37 Email::Sender::Role::CommonSending::send('Email::Sender::Simple', 'Ema +il::Simple =HASH(0x99659c)') called at C:\strawberry\perl\site\lib\Sub\Exporter\U +til.pm lin e 69 Sub::Exporter::Util::__ANON__('Email::Simple=HASH(0x99659c)') called a +t C:\Docum ents and Settings\Administrator\Desktop\perl experiments\mail sender.p +l line 9
    So I tried to add a use Email::Simple::Creator; line
    but nothing changed.

    help :-(
        Running a server ???
        Don't I just need to refer it to
        C:\Program Files\Git\bin\msmtp.exe or something like that ?
        That was the idea I got from Email::Sender,
        or is that counts as running a server ?
        Your 1st link refers to a "host" & a "port", how can I figure out what should these be set to ?

        Thx

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://925273]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2014-12-25 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (161 votes), past polls