Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

by sago (Scribe)
on Jun 29, 2007 at 10:14 UTC ( [id://624072]=note: print w/replies, xml ) Need Help??


in reply to how do i send an email with perl in window system

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()

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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://624072]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-03-28 19:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found