Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Sending Mail trough Perl using ActivePerl on windows

by sago (Scribe)
on Jun 20, 2007 at 06:43 UTC ( #622187=note: print w/ replies, xml ) Need Help??


in reply to Sending Mail trough Perl using ActivePerl on windows


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

One is using the module Mail::Sendmail and the other is using the module MIME::Lite.

Program 1 using the module Mail::Sendmail.

#!C:/Perl/bin/perl.exe
use Mail::Sendmail;
my $to_list = 'john@gmail.com';
my $cc_list = 'frank@yahoo.com';
my $email = "\n\nThis email was generated automatically.\n";
my $MailFrom = "test\@gmail.com";
my $subject = "hello test";
my $message = "module test";
%mail = (
To => $to_list,
From => $MailFrom,
Bcc => $bcc_list,
Cc => $cc_list,
Subject => $subject,
Message => $message
);
$mail{Smtp} = 'mailtest.gmail.com';
sendmail(%mail)


Program 2 using the module MIME.

#!C:/Perl/bin/perl.exe
use MIME::Lite;
MIME::Lite->send('smtp', "mailtesthub.gmail.com", Timeout=>90);
my $email = "This email was generated automatically.";
my $subject = "hello test";
my $MailFrom = "john@gmail.com";
my $to_list = 'frank@yahoo.com';
my $cc_list = 'sam@rediffmail.com';
$msg = MIME::Lite->new(
From => $MailFrom,
To => $to_list,
Cc => $cc_list,
Bcc => $bcc_list,
Subject => $subject,
Type => 'TEXT',
Encoding=> '7bit',
Data => $a
);
$msg->send()


Comment on Re: Sending Mail trough Perl using ActivePerl on windows
Re^2: Sending Mail trough Perl using ActivePerl on windows
by the_hawk_1 (Scribe) on Jun 20, 2007 at 16:27 UTC
    Thanks a lot!

    with the use of lib and Mail::Sendmail, I've finaly be able to send my email alerts, and moreover, I find out to be able to send an .xls file attached to it.

    Thanks to all of you who helped me!

      Hi, I am using activeperl and tried to send mail using the Mail::sendmail code provided by you. I am not getting errors when i run the perl script but my also doesn't go. here is my script. How do I provide login information to the gmail server, or is it not required? Is this the right way? #!C:/Perl/bin/perl.exe use Mail::Sendmail; print "Hello World1.\n"; my $to_list = 'gsarin83@gmail.com'; my $cc_list = 'aryan_42k@yahoo.com'; my $email = "\n\nThis email was generated automatically.\n"; my $MailFrom = "gs.engr@gmail.com"; my $subject = "hello test"; print "Hello World2.\n"; my $message = "module test"; %mail = ( To => $to_list, From => $MailFrom, Bcc => $bcc_list, Cc => $cc_list, Subject => $subject, Message => $message ); $mail{Smtp} = 'smtp.gmail.com'; sendmail(%mail); print "Hello World3.\n"; Thanks, Gaurav
      Hi, I am using activeperl and tried to send mail using the Mail::sendmail code provided by you. I am not getting errors when i run the perl script but my also doesn't go. here is my script. How do I provide login information to the gmail server, or is it not required? Is this the right way?
      Hi I am also wroking on same task( Sending email when ever there is error in logs) to know how to lib please can u share your perl program. by refering your program i can complete my task. don't have Mail::Mailer & Mail::Sendmail; installed.
Re^2: Sending Mail trough Perl using ActivePerl on windows
by Anonymous Monk on Oct 24, 2009 at 20:17 UTC
    #!C:/Perl/bin/perl.exe use warnings; use Mail::Sendmail; my $to_list = 'someone@gmail.com'; my $email = "\n\nThis email was generated automatically.\n"; my $MailFrom = 'dipeshkumar.dutta@gmail.com'; my $subject = "hello test"; my $message = "module test"; %mail = ( To => $to_list, From => $MailFrom, Subject => $subject, Message => $message ); $mail{Smtp} = 'smtp.gmail.com'; sendmail(%mail)or die $Mail::Sendmail::error; print "OK. Log says:\n", $Mail::Sendmail::log;
    I am using the above script but facing the following error.
    MAIL FROM: error (530 5.7.0 Must issue a STARTTLS command first. 5sm12 +048018qwg.10)
    Can any body help me to fis this error. Thanks in Advance!
Reaped: Re^2: Sending Mail trough Perl using ActivePerl on windows
by NodeReaper (Curate) on Oct 24, 2009 at 20:18 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (15)
As of 2014-09-16 13:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (24 votes), past polls