send e-mail using perl .

How to send e-mail using perl. give some programming example code
pandianAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GnissmanCommented:
use Mail::Send;

$mail=Mail::Send->new(
  Subject => "Important News!",
  To => "foo@bar.com",
  Cc => "bigbird@neverland.com",
  Bcc => 'littlebird@neverland.com");

$mail->set("From", "me@you.com");
$mail->set("Reply-To", "me@here.com");

$mailhandle = $mail->open("sendmail");

print $mailhandle <<EOT;
This is
my message.
EOT

$mailhandle->close();

-----------------------------------
Hope this helps,
Gniss
0
pandianAuthor Commented:
Thank you gnissman.
i want to know about the use mail::send;
..if it is a package. i have no that named packaged. where can i get it and how to implement it. please help me.
0
pandianAuthor Commented:
Thank you gnissman.
I want to know about the use mail::send;
..If it is a package. I have no that named packaged. where can i get it and how to implement it. Please help me.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

GnissmanCommented:
Like every other module you can find it at
http://www.cpan.org 

You find Mail::Send at
http://search.cpan.org/search?module=Mail::Send

Download the file MailTools-1.13.tar.gz and extract its contents to any folder on your harddisk.

You install the library by running these commands:

   perl Makefile.PL
   make
   make test
   make install

Afterwards my example code from above should work!

Gniss
0
olthoffCommented:
With out the module

open(MAIL, '|sendmail -t');
print("TO: $To\n");
print("FROM: $From\n");
print("SUBJECT: $Subject\n\n");
print("$MessageBody\n");
close(MAIL);
0
pandianAuthor Commented:
gnissman i did what you said.
while running the makefile.pl some error

can't locate extUtils/MakeMaker.pm in @INC at makefile.pl line 12
BEGIN failed--compilation aborted at makefile.pl line 12
can it rectify?
0
GnissmanCommented:
Your Perl installation seems to lack the module MakeMaker.pm

Please download it at

http://www.cpan.org/modules/by-authors/Andreas_K%f6nig/MakeMaker-5.41.tar.gz

and install it using

perl Makefile.PL
make install

Afterwards you will be able to install Mail::Send as described!

Gniss
0
pandianAuthor Commented:
can explain about 'the makemaker'.
please gnissman. and how to install perl program. Where can i get it.
0
GnissmanCommented:
I thought you already had perl installed?
Maybe you should define the problem more clearly.

As far as I understand it's the following:
You have a working Perl installation on your computer.
You know how to program in Perl.
You want to send mails from within your script.
You want to know how to install the module you need.

So here is the step-by-step guide:

download this file

http://www.cpan.org/modules/by-authors/Andreas_K%f6nig/MakeMaker-5.41.tar.gz

and save it to your local drive. Expand it to a folder. Switch to the DOS-mode and enter the that folder. Now enter

perl Makefile.PL
make install

Now switch back to windows and delete the contents of that folder. Download the file at

http://search.cpan.org/search?module=Mail::Send 

save and extract it to that folder again. Switch do DOS, go to that folder and enter

perl Makefile.PL
make
make test
make install

Now close the DOS-box, delete the contents of the folder and execute the script from my first comment.

If anything still goes wrong, please post the error-message.

And by the way, if you can I wouldn't mind you increasing the points for this question a little... :o)

Gniss


0
pandianAuthor Commented:
gnissman,
I followed the instruction. which you gave. while i was doing some error came.
this file is not there, that file is not there. finding those files i put in the directry. and i run the command in dos prompt perl makefile.pl.
it displays some messages those are
checking if your kit is complete...
Looks good
Error: Unable to locate installed perl libraries or perl source code.
It is recommended that you install perl in a standard location before building extensions. Some precompiled versions of perl do not contain these header files, so you cannot build extensions. in such a case, please build and install you perl from a fresh perl distribution. I useually solves this kind of problem.
<You get this message. because MakeMaker could no find "\CORE\perl.h">

this is the error message i got

I copied  all the perl programme files from the other system instead of installing.  Because there is no installable version. I think this may be problem to compile the makefile.pl

give some solution

Thank you.
0
GnissmanCommented:
Copying perl will not work, you will have to install perl to run properly. Otherwise some environment-variabled and paths will not be set.

Which is your operating system?

Gniss
0
pandianAuthor Commented:
windows NT, gnissman.
0
GnissmanCommented:
In that case I you should download a new Perl installation from

http://www.activestate.com/ActivePerl/download.htm

and run the setup. Once Perl is properly installed you do not need to install MakeMaker (it comes with ActiveState Perl), so all you have to do is install Mail::Send as described above.

Let me know if it worked...

Gniss

PS: never written so much comments for 15 pts :o)
0
pandianAuthor Commented:
I clicked the link which you specify. But it could not go that site. 'cannot find server' error message displayed. I also tried to go to the www.activestate.com site. But it also didn't work, gniss
0
GnissmanCommented:
This must be a temporaly problem in your region. I downloaded the latest release just an hour ago from that URL.
Keep on trying... ;-)

Gniss
0
MindoCommented:
Man, try the following code to e-mail a message. It wraps all the sendmail features and makes it a lot easier. Look, the solution is:

========================================
#!/usr/local/bin/perl -w

use Mail::Mailer;

$mailer = Mail::Mailer->new();
$mailer->open({ From => $from_address,
                To   => $to_address,
                Subject => $subject,
             })
     or die "Can't open: $!\n";
print $mailer $body;
$mailer->close();
========================================
0
khacharnCommented:
hi..
if your using WinNT OS then you can use A command line program Blat to send mails from your command line promot..
believe me it is simply superb i have been using it to create my mailing list script..
mail me at khacharn@yahoo.com
if you want a copy of my script and blat
Regards Nitin
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.