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
Avatar of GarbsTheTurtle
GarbsTheTurtle
Flag of United States of America image

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

Avatar of ISHUC
ISHUC
Flag of United States of America image

ASKER

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
Avatar of GarbsTheTurtle
GarbsTheTurtle
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
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
Avatar of ISHUC
ISHUC
Flag of United States of America image

ASKER

you're awesome!
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo