Solved

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

Posted on 2008-10-10
5
573 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
[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
  • 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
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.

623 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