Solved

Sending mail from cgi

Posted on 2000-02-17
5
165 Views
Last Modified: 2010-03-05

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?
0
Comment
Question by:leoleo
[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
5 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 2534199
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
 

Author Comment

by:leoleo
ID: 2534415

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
 
LVL 3

Expert Comment

by:alien_life_form
ID: 2534558
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
 

Expert Comment

by:Spearmon
ID: 2537400
ive seen a great smtp example at http://616.org doesnt use sendmail and is faster to
0
 
LVL 1

Accepted Solution

by:
kawin earned 50 total points
ID: 2539350
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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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

695 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