Jump to content

Archived

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

Janus13

mail() help

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
But does "nobody" still originate the email? I'll give this a try and see if it makes any difference.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.