Avatar of ISHUC
ISHUCFlag for United States of America asked on

Suse / Apache mail. Sender is WWW daemon apache.

I'm on a SUSE 11 box.
I am sending emails from a php script but the from address is showing WWW daemon apache.  How do I change this?  It is not accepting the "from" code that works on a Windows / Apache box.
ini_set('sendmail_from', 'sendername@mailserver.com');
 
	$emailaddr="recipient@mailserver.com";
 
	$mailsend = mail($emailaddr, $subj, $mess, $headers);

Open in new window

Programming Languages-OtherPHPApache Web Server

Avatar of undefined
Last Comment
ISHUC

8/22/2022 - Mon
GarbsTheTurtle

You use $headers in your mail() call, but I don't see $headers being set anywhere. Have you set the From: attribute in $headers? See http://us3.php.net/manual/en/function.mail.php for more headers to pass.

ini_set('sendmail_from', 'sendername@mailserver.com');
 
        $emailaddr="recipient@mailserver.com";
 
        $headers = 'From: webmaster@example.com' . "\r\n";
        
        // Other headers
        //$headers .= 'Reply-To: webmaster@example.com' . "\r\n";
        
        $mailsend = mail($emailaddr, $subj, $mess, $headers);

Open in new window

ASKER
ISHUC

The reason that I did use the $headers (or left is blank) is that depending on the selections,  it could come from 2 different accounts.
$destination='file_uploads'."/".$_POST[Req_ID].'_'.$passedfile;
$piemail=$_POST[PI_email];
$piname=$_POST[PI_Name];
 
$subj=$_POST[Req_ID]."_".$_POST[Note_Date]."_".$piname."_".$_POST[group]."_Research Central Project";
 
$mess='This is an automated email from the Research Central Notes system.
Request ID: '.$_POST[Req_ID].'
Note Date: '.$_POST[Note_Date].'
Note Time: '.$_POST[Note_Time].'
Time Spent: '.$_POST[timespent].'
Author: '.$_POST[Note_Person].'
CCTST Affiliation: '.$_POST[group].'
Ticket Inactive: '.$_POST[activestatus].'
Notes: '.$_POST[Notes];
$headers = '';
//*********************************************************
if ($_POST[Email_CCHMC_Informatics] == "yes")
	{
	if($_POST[Email_Investigator] == "yes")
		{
		ini_set('sendmail_from', $piemail);
		}
	Else
		{
		ini_set('sendmail_from', 'researchcentral@ucmail.uc.edu');
		}
 
	$emailaddr="cchmcinformatics@cctst.cchmc.org";
 
	$mailsend = mail($emailaddr, $subj, $mess, $headers);
	//  echo "<h1><center>Mail sent</center></h1>";
	}
 
	

Open in new window

ASKER CERTIFIED SOLUTION
GarbsTheTurtle

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
GarbsTheTurtle

Also note that ini_set('sendmail_from', ... ) only works on windows. Now that you're on a Linux system, you can remove those ini_set() lines.

http://us2.php.net/manual/en/mail.configuration.php#ini.sendmail-from
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER
ISHUC

you're awesome!