Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 2 > Installation/Configuration

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 26th February 2007, 13:52
bwragg bwragg is offline
Member
 
Join Date: Jul 2006
Posts: 58
Thanks: 7
Thanked 3 Times in 2 Posts
Post php mail() sent as apache@server.domain.com

if I do the following in a php page

Code:
if (mail($ADDR,"Testing","This is a test"))
the mail gets sent from apache@servername.domainname.com. I assume this is happneing becuase the httpd server is running as the apache user? Is there any way to stop this so that the email is sent automatically from the domain the page is being run in?

I know you can add the $header parameter to the mail function with a "From:" statement in it, but is there anyother way.

Thanks,

Ben
Reply With Quote
Sponsored Links
  #2  
Old 26th February 2007, 14:10
Ben Ben is offline
Moderator
 
Join Date: Jul 2006
Posts: 1,029
Thanks: 7
Thanked 62 Times in 56 Posts
Default

You can change the sendmail_path of php.ini
so that you add -fsenderadress@senderdomain.com
to php.ini in general or you set this value via php_admin_value in the httpd.conf per vhost.
Reply With Quote
  #3  
Old 26th February 2007, 23:17
bwragg bwragg is offline
Member
 
Join Date: Jul 2006
Posts: 58
Thanks: 7
Thanked 3 Times in 2 Posts
Default

So for each domain do I need to add this to the apache directives:

php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -fuser@thisdomain.com'

Does that look correct?

I tried the sendmail_from parameter, but that didn't do a thing. Don't know why?

Cheers,

Benjamin
Reply With Quote
  #4  
Old 27th February 2007, 00:07
edge edge is offline
Moderator
 
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,044
Thanks: 269
Thanked 154 Times in 133 Posts
Default

If you add a "from" email address in the PHP mail() , it will use that instead of the apache@server.domain.com
You will need to add it in the "headers"

Code:
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
__________________
Never execute code written on a Friday or a Monday.

Last edited by edge; 27th February 2007 at 00:09.
Reply With Quote
  #5  
Old 27th February 2007, 01:07
bwragg bwragg is offline
Member
 
Join Date: Jul 2006
Posts: 58
Thanks: 7
Thanked 3 Times in 2 Posts
Default

That works great, Thanks.

Is the reason its being sent by apache due to the fact that apache is the user that is running php?

If I setup my system differently so that php was running using something like suphp would the email go out via the owner of the file rather than the apache user?

Thanks,

Benjamin
Reply With Quote
  #6  
Old 27th February 2007, 09:33
Ben Ben is offline
Moderator
 
Join Date: Jul 2006
Posts: 1,029
Thanks: 7
Thanked 62 Times in 56 Posts
Default

If you set the Header From, just remember that this is only the X-Header, i mean it is never the less displayed in the email riht, but in the header you can see the "original" E-mailadress anyway, just fyi.
Reply With Quote
  #7  
Old 13th February 2013, 08:49
Emile van EWeden Emile van EWeden is offline
Junior Member
 
Join Date: Feb 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default re

I there.
I have the same issue when sending email using php. I also tried the example by the user "edge" with no luck. What else can I try? Thank you

Code:
Feb 13 06:55:30 mailer postfix/qmgr[1273]: 4BB1E1D3A4: from=<apache@serv2.wugnet>, size=473, nrcpt=1 (queue active)
Feb 13 06:55:33 mailer postfix/smtp[2507]: 4BB1E1D3A4: to=<userx@wugnet.com>, relay=smtp.wugnet.com[221.52.0.17]:25, delay=3.8, delays=0.86/0.03/1.8/1.1, dsn=2.0.0, status=sent (250 OK id=1U5Vyp-0006Ba-G0)
Reply With Quote
  #8  
Old 13th February 2013, 09:46
edge edge is offline
Moderator
 
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,044
Thanks: 269
Thanked 154 Times in 133 Posts
Default

You can try by adding the -f option to it.

Somtehing like this: mail($to,$subject,$message,$headers,"-f".$from);
__________________
Never execute code written on a Friday or a Monday.
Reply With Quote
  #9  
Old 13th February 2013, 10:28
Emile van EWeden Emile van EWeden is offline
Junior Member
 
Join Date: Feb 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi still doing the same
Reply With Quote
  #10  
Old 18th February 2013, 16:10
Emile van EWeden Emile van EWeden is offline
Junior Member
 
Join Date: Feb 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

Hi i got it working by editing ssmtp.conf.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Freebsd 6.1 support misterm Installation/Configuration 10 9th April 2009 10:29
Slightly Confused (DNS & Server Help) JohnnyBGoode Installation/Configuration 26 14th August 2007 10:54
Postfix reject connections gabrix Server Operation 27 25th January 2007 09:37
Core 4: Error Messages on Fresh Install re CTX/SSL jjw Installation/Configuration 30 6th September 2006 13:16
Virtual Users And Domains With Postfix, Courier And MySQL (+ SMTP-AUTH, Quota, SpamAs ebbay Installation/Configuration 9 4th March 2006 12:47


All times are GMT +2. The time now is 19:07.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.