boxturt Posted January 16, 2008 Posted January 16, 2008 I recently modified a (php) calendar script to notify admin (me) whenever a registered user posts an event. I simply added: ><?php mail( "calendar@mysite.org", "Event $month / $day / $year", $text, $title ); ?> and I get the information. Problem is it comes from Nobody@mytchserver.here. Ok, Nobody owns the script right? So how can I get the email to be sent from the site? Spam filters go crazy with mail from Nobody. Probably an easy fix but I'm just not seeing it. Thanks for any input, it's always appreciated. Ty Quote
Jeren Posted January 16, 2008 Posted January 16, 2008 http://us.php.net/manual/en/function.mail.php What you want would be part of the header. Take a look at Example #2 on that page. It should be helpful. Quote
TCH-Andy Posted January 16, 2008 Posted January 16, 2008 Example 3 on the link Jeren gave should also help ><?php mail( "calendar@mysite.org", "Event $month / $day / $year", $text, $title, "-fmyscript@mysite.com"); ?> Quote
boxturt Posted January 16, 2008 Author Posted January 16, 2008 Thanks guys, much appreciated. #3 gave the right 'from' address but kept sending as Nobody <calendar@mysite.org> so I ended up with: ><?php $to = 'calendar@mysite.org'; $subject = "Event Added $month / $day / $year"; $message = "$title\n\n $text"; $headers = 'From: calendar@mysite.org' . "\r\n" . 'Reply-To: calendar@mysite.org' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?> which sends to the right address with no name attached, which is fine! Thanks again. Quote
TCH-Bruce Posted January 16, 2008 Posted January 16, 2008 Change the mail line to add a from of your choosing. >mail($to, $subject, $message, $headers "-f".sendfrom@domain.ext) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.