Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-10-10
5
Medium Priority
?
585 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 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

670 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