Janus13 Posted March 2, 2006 Share Posted March 2, 2006 I am seeing some odd behavior out of the mail function. I run a member management package on Apache with mysql and php 4. When the mail functions get invoked sometimes exim mail servers will reject the mail because it appears to originate from nobody@server. Is there a way to specify a user for the mail function to send from so they don't get rejected? Quote Link to comment https://forums.phpfreaks.com/topic/3882-mail-help/ Share on other sites More sharing options...
Hooker Posted March 2, 2006 Share Posted March 2, 2006 Try something like this:[code] $email = "whoever@yourmailing.com"; $subject = "Subject!"; $body = "whatever you want to email"; $from = "From: Emailers Name <email@address.com>"; mail($email,$subject,$body,$from);[/code]it should do exactly what you need, you can always put the details directly into the mail() function but i prefer to have them in variables outside of the function. Quote Link to comment https://forums.phpfreaks.com/topic/3882-mail-help/#findComment-13482 Share on other sites More sharing options...
Janus13 Posted March 4, 2006 Author Share Posted March 4, 2006 But does "nobody" still originate the email? I'll give this a try and see if it makes any difference. Quote Link to comment https://forums.phpfreaks.com/topic/3882-mail-help/#findComment-14121 Share on other sites More sharing options...
Hooker Posted March 4, 2006 Share Posted March 4, 2006 Heres the difference:[code] $from = "From: Emailers Name <email@address.com>";[/code]The mail will be listed as from "Emailers Name" and also have the return address of "email@address.com" some spam filters may look at the header info of the email but it should work fine for most. Quote Link to comment https://forums.phpfreaks.com/topic/3882-mail-help/#findComment-14198 Share on other sites More sharing options...
kenrbnsn Posted March 4, 2006 Share Posted March 4, 2006 You probably need to use the fifth parameter to the mail() function to change the "Return-path:" header to include the domainname you're sending from.[code]<?php$p5 = '-f somename@yourdomainname.com';mail($to,$subj,$mesg,$from,$p5);?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/3882-mail-help/#findComment-14247 Share on other sites More sharing options...
Janus13 Posted March 5, 2006 Author Share Posted March 5, 2006 So this should work ok?[code]function mymail($to,$subject,$message,$from){$option = "-f me@mydomain.com";mail($to,$subject,$message,$from,$option);}$to = "someone@someone.com";$subject = "Test Email";$message = "This is a test message";$from = "From: My Site <me@mydomain.com>";mymail($to,$subject,$message,$from);[/code]Also, the earlier suggestion doesn't seem to make any difference, so I'm hoping the last option will work. Quote Link to comment https://forums.phpfreaks.com/topic/3882-mail-help/#findComment-14315 Share on other sites More sharing options...
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.