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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.