?
Solved

sending an email with cgi

Posted on 2003-03-11
4
Medium Priority
?
231 Views
Last Modified: 2013-12-25
I want to send an email using cgi (written in perl). I get the following error message: "Bad header=Recipient names must be specif:"

Here's the simple sub routine I wrote to send the email:

sub sendEmail {
     ($myEmail, $myMsg) = @_;
     $mailprog= "/usr/sbin/sendmail";
     $recipient= "$myEmail";    
     $body = "This is the email message. $myMsg";
         
     open (MAIL, "|$mailprog") || die "Couldn't open the mail program: $!";
     print MAIL     "To: $recipient\n";
     print MAIL     "Subject: $subject\n";
     print MAIL     "$body\n";
     close MAIL;
}

It's called like this: &sendEmail($email, $msg);

What am I doing wrong? Any help will be appreciated. Thanks.
Jason
0
Comment
Question by:hgajas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 2

Accepted Solution

by:
antonsigur earned 500 total points
ID: 8113591
$mailprog = '/usr/sbin/sendmail';
$recipient = 'name@somewhere.com;

open (MAIL, "|$mailprog -t") or dienice("Can't access $mailprog!\n");

print MAIL "To: $recipient\n";
#print MAIL "Reply-to: $recipient\n";
print MAIL "subject: Form Data\n\n";

print 'The body text';

close(MAIL);


This is working for mee....
0
 
LVL 2

Expert Comment

by:antonsigur
ID: 8113608
You forgot the double \n\n

in print MAIL "subject: Form Data\n\n"; If that matters...
0
 
LVL 2

Expert Comment

by:antonsigur
ID: 8113623
This is the error :
  $recipient= "$myEmail";

remove the "'s

Or better, replace $myEmail with $recipient
0
 

Author Comment

by:hgajas
ID: 8113770
Thanks for all three of the quick responses.
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Suggested Courses

762 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