?
Solved

send e-mail using perl .

Posted on 1999-11-22
17
Medium Priority
?
301 Views
Last Modified: 2010-03-05
How to send e-mail using perl. give some programming example code
0
Comment
Question by:pandian
17 Comments
 
LVL 1

Expert Comment

by:Gnissman
ID: 2224506
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
 

Author Comment

by:pandian
ID: 2224564
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
 

Author Comment

by:pandian
ID: 2224568
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
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
LVL 1

Expert Comment

by:Gnissman
ID: 2224579
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
 
LVL 1

Expert Comment

by:olthoff
ID: 2225021
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
 

Author Comment

by:pandian
ID: 2230812
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
 
LVL 1

Expert Comment

by:Gnissman
ID: 2230857
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
 

Author Comment

by:pandian
ID: 2233418
can explain about 'the makemaker'.
please gnissman. and how to install perl program. Where can i get it.
0
 
LVL 1

Expert Comment

by:Gnissman
ID: 2233619
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
 

Author Comment

by:pandian
ID: 2233706
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
 
LVL 1

Expert Comment

by:Gnissman
ID: 2233721
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
 

Author Comment

by:pandian
ID: 2235295
windows NT, gnissman.
0
 
LVL 1

Expert Comment

by:Gnissman
ID: 2235563
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
 

Author Comment

by:pandian
ID: 2235608
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
 
LVL 1

Expert Comment

by:Gnissman
ID: 2235666
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
 
LVL 2

Expert Comment

by:Mindo
ID: 2256865
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
 

Accepted Solution

by:
khacharn earned 100 total points
ID: 2331222
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Article by: Tammy
MySQLTuner is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and presented in a brief forma…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question