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()
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.