Solved

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

Posted on 2008-10-10
5
561 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 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

756 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