Jump to content

mail() help


Janus13

Recommended Posts

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?
Link to comment
https://forums.phpfreaks.com/topic/3882-mail-help/
Share on other sites

Try something like this:

[code]
      $email = "[email protected]";
      $subject = "Subject!";
      $body = "whatever you want to email";
      $from = "From: Emailers Name <[email protected]>";
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.
Link to comment
https://forums.phpfreaks.com/topic/3882-mail-help/#findComment-13482
Share on other sites

Heres the difference:

[code]      $from = "From: Emailers Name <[email protected]>";[/code]

The mail will be listed as from "Emailers Name" and also have the return address of "[email protected]" some spam filters may look at the header info of the email but it should work fine for most.
Link to comment
https://forums.phpfreaks.com/topic/3882-mail-help/#findComment-14198
Share on other sites

So this should work ok?

[code]
function mymail($to,$subject,$message,$from){

$option = "-f [email protected]";
mail($to,$subject,$message,$from,$option);
}

$to = "[email protected]";
$subject = "Test Email";
$message = "This is a test message";
$from = "From: My Site <[email protected]>";
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.
Link to comment
https://forums.phpfreaks.com/topic/3882-mail-help/#findComment-14315
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.