Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PHP  mail function:  how to affect the Return-Path parameter

Posted on 2008-10-10
5
Medium Priority
?
590 Views
Last Modified: 2012-05-05
From a web-based script within a hosting account, i want to send an email from a PHP script.
Everything works fine, except the Return-Path seems to always be the system default (in the system php.ini)
How can i change this on a per user or per script basis?

I tried the suggestion   From:  First LastName<email@domain.com>
which comes thru fine as the From address in the message header, but the Return-Path in the header
still says   nobody@myserver.com

any advice?
0
Comment
Question by:willsherwood
  • 3
  • 2
5 Comments
 
LVL 11

Accepted Solution

by:
bansidhar earned 2000 total points
ID: 22688159
try using

mail('nobody@example.com', 'the subject', 'the message', 'additional headers',  '-fwebmaster@yourdomain.com');

this works if your MTA is sendmail
0
 

Author Comment

by:willsherwood
ID: 22688254
this seems only to affect the From address, not the Return-Path
address listed in the headers.

I even tried putting a php.ini in the root of the user account  (however, when i run  phpinfo.php
it shows:
sendmail_from      no value    )

so maybe that should be my question.
0
 
LVL 11

Expert Comment

by:bansidhar
ID: 22688470
try also adding Return-Path: <webmaster@yourdomain.com> to the additional header like

mail('nobody@example.com', 'the subject', 'the message', "Return-Path: <webmaster@yourdomain.com>\n",  '-fwebmaster@yourdomain.com');

but the first method I suggested have to work with sendmail the last parameter is the option for sendmail. This requires that your send mail can send mails using the email address you are providing.

check for the sendmail details here
http://www.courier-mta.org/sendmail.html
0
 

Author Comment

by:willsherwood
ID: 22690472
sorry, but i'm already in a custom script and am using the built-in PHP mail() function directly.
(It has nothing to do with a webform or the traditional sendmail or formmail type of feature)

I need to know how to set the value that is contained in the message header for  Return-path.
It's currently picking up the default server email address as defined in (Cpanel) WHM root.

I've tried putting     Return-path:     as an additional parameter in the  header string given to the mail() function,  and i've tried (quickly/temporarily) changing the php.ini file for the entire server, and neither of these techniques affect the  resulting  Return-path in a received message header.   (I did verify in phpinfo.php that the sendmail_from  was affected  in this latter test)
0
 

Author Closing Comment

by:willsherwood
ID: 31505073
thanks
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

772 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