Sending mail from cgi


Hi,

  I use sendmail program to send mails from my CGI program, like this:


open(SEND_MAIL, "|/usr/sbin/sendmail -t");

print SEND_MAIL "To\: $to\n";
print SEND_MAIL "From\: $from\n";
print SEND_MAIL "Subject\: $subject\n\n";
print SEND_MAIL $body;
print SEND_MAIL "\n\n";
close(SEND_MAIL);


When the mail reaches the recipient, the "to", "from" etc values are all correct, just as I had given, but in the header, I see the "return-path" as "nobody". I want the "from" address itself to be seen as the return-path.

What can be done?
leoleoAsked:
Who is Participating?
 
kawinConnect With a Mentor Commented:
Try this module Mail::Sender it easier than write your own code :) Or you can search other mail sender module from http://search.cpan.org.
0
 
ozoCommented:
Return-Path: should only be added on the host that performs final delivery.
In general, it should never be used for replying to mail.  It is solely intended to be used for notification of delivery errors.
Perhaps you wanted to set the Reply-To: header?
0
 
leoleoAuthor Commented:

Isn't Return-Path used if the mail bounces ?

I want it to be the same as the 'from' address. I have seen automatically generated mails from several sites which have the 'from' address at the Return-Path header as well. So I know it's possible.

0
 
alien_life_formCommented:
One way would be to use the -f switch
to sendmail (sendmail -f foo -bt). This requires 'trust' privileges, and I doubt if it's wise to grant them to 'nobody',  which is probably the user your webserver is running under.

Another way would be making the script
suid to some real user (the From: user).
0
 
SpearmonCommented:
ive seen a great smtp example at http://616.org doesnt use sendmail and is faster to
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.