Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Answer: how do i send an email with perl in window system

( #624072=categorized answer: print w/ replies, xml ) Need Help??

Q&A > mail and news > how do i send an email with perl in window system contributed by sago

Please see the below two programs to send mail through perl using activeperl on windows.

The first uses Mail::Sendmail and the second uses MIME::Lite.

use Mail::Sendmail; my $MailFrom = 'test@gmail.com'; my $to_list = 'john@gmail.com'; my $cc_list = 'frank@yahoo.com'; my $subject = "hello test"; my $message = "This email was generated automatically.\n"; sendmail( Smtp => 'mailtest.gmail.com', From => $MailFrom, To => $to_list, Cc => $cc_list, Subject => $subject, Message => $message, );
use MIME::Lite; MIME::Lite->send('smtp', "mailtesthub.gmail.com", Timeout=>90); my $MailFrom = 'test@gmail.com'; my $to_list = 'john@gmail.com'; my $cc_list = 'frank@yahoo.com'; my $subject = "hello test"; my $message = "This email was generated automatically."; my $msg = MIME::Lite->new( From => $MailFrom, To => $to_list, Cc => $cc_list, Subject => $subject, Type => 'TEXT', Encoding => '7bit', Data => $message, ); $msg->send()

Comment on Answer: how do i send an email with perl in window system
Select or Download Code
Replies are listed 'Best First'.
Answer: how do i send an email with perl in window system
by jettero (Monsignor) on Jun 29, 2007 at 10:22 UTC
    You could also save yourself some vertical space and try (my) Net::SMTP::OneLiner. There is a lot of stuff it doesn't do, but it's nice for cron jobs and things.
    use strict; use Net::SMTP::OneLiner; send_mail( 'from@me', ['to1@you', 'to2@you'], "subject", "message\nmes +sage\nmessage\n" );

    -Paul

      Hello Paul, I was looking for this and I tried your steps exactly what you have stated above for sending emails in Perl using Net::SMTP::OneLiner. But unfortunately it is not working for me. I don't know what I have made wrong as I'm very new to Perl but just followed exactly your steps. Could you please let me know what I need to do in order to work? Thanks, Sachin
        I can't tell you how to fix it until you tell me what went wrong. Enable the debugging and report back with your findings and we'll see what we can do.

        -Paul

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2015-07-28 04:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (252 votes), past polls