Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-07-2004, 01:07 AM   #1
LQ Newbie
Registered: Feb 2004
Posts: 16

Rep: Reputation: 0
perl send mail code

system("perl /home/amarvir/ANYMEDIA/bin/ -f PORTTEST_SERVER\@MOH -t suchi.sood\ -s \"Report for Faulty ports \" ". $maildir.$_) ;

how to use this code to send it to multi user
Old 06-07-2004, 02:28 AM   #2
Registered: Mar 2004
Location: bursa
Posts: 110

Rep: Reputation: 15
I have no idea what is, but can't you just:
my @recipients = ('person_one', 'person_two', 'person_three');

my $subject = '"Report for Faulty ports"';
my $mailer = '/home/amarvir/ANYMEDIA/bin/';

foreach my $recipient (@recipients) {
        system("$mailer -f $from -t $recipient -s $subject $maildir$unknown");
Where $unknown is whatever the heck $_ was supposed to be(?). You sure don't give us much to work with.

edit: of course, assuming handles -t in a sane way, you should be able to feed it the list of recipients, separated by commas (ie. join ',',@recipients;)

Last edited by rkef; 06-07-2004 at 06:01 PM.
Old 03-17-2006, 06:48 PM   #3
Senior Member
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
if you want to use Perl to send mail, you need to do two things:

1) Install "sendmail" on your computer.

2) To actually SEND the mail, you need to open a filestream to the sendmail so:
unless(open(SENDMAIL, "| $sendmailpath -t")) { die; }
Then, you just pipe everything to sendmail with a print statement as an HTML file. I suggest using the CGI Perl module (for working with the to-be-created HTML pages). So, the crucial lines of your Perl script should look something like this:
#!/usr/bin/perl -w
use CGI;
print header();
print html_start();
unless(open(SENDMAIL, "| $sendmailpath -t")) { die "ERROR!"; }
print (SENDMAIL, $variable);
I hope that helps.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Send Mail with Perl Cool_Hand_Luke Programming 2 03-14-2005 10:59 AM
Perl form wont send mail calmbomb Linux - Software 4 11-07-2004 11:08 AM
How can i attach my code with send mail server ? irfanyar Linux - General 1 03-14-2004 04:42 PM
howto send a mail with attachment via perl script ? cccc Programming 24 03-05-2004 08:49 PM
I'm looking for a simply perl script to send mail, when ping down cccc Programming 2 01-12-2004 05:36 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:47 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration