Solved

Sending mail from cgi

Posted on 2000-02-17
5
159 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
5 Comments
 
LVL 84

Expert Comment

by:ozo
Comment Utility
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
Comment Utility

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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now