Solved

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

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

706 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

19 Experts available now in Live!

Get 1:1 Help Now