Jump to content

Php Mail Script Needed


wayne

Recommended Posts

I have been told by the help desk that my php script which sends out an email receipt is no longer allowed on my server. It was a basic command in the form to

mail($recipient,$subject,$body,$from)

 

The reason is that it is sending out mail as nobody which is no longer allowed.

 

I have many many php pages that use this script to send out receipts to customers. Is there a way to use php to send mail and not have it send it a "nobody". I do put a reply address in the $from variable but obviously that is not what is needed.

 

 

Thanks in advanced.

Link to comment
Share on other sites

Thanks

 

I have found this reference to the -f switch

 

<?php

mail('nobody@example.com', 'the subject', 'the message', null,

'-fwebmaster@example.com');

?>

 

Not sure what the null is. Do I leave this as null? What I want is an email sent out to my customer and to bcc myself.

Would this work?

 

<?php

mail('customer@example.com', '$subject', '$message', null,

'-fmyaddress@****');

?>

 

Not sure how I would get this to bcc me as well or can I do this?

Link to comment
Share on other sites

Hi Wayne,

 

The null that you have should really be the headers;

 

Try;

 

>$fromname = "me"; 
$fromemail = "me@here.com"; 

$toname = "you"; 
$toemail = "you@there.com"; 

$subject = "subject of email"; 

$message = "Test message\n"; 
$message .= "\n"; 
$message .= "signed\n"; 

$headers = "From: $fromname <$fromemail>\r\n"; 
$headers .= "Reply-To: $fromname <$fromemail>\r\n"; 
$headers .= "To: $toname <$toemail>\r\n"; 
$headers .= "bcc: $fromname <$fromemail>\r\n"; 
$headers .= "MIME-Version: 1.0\r\n"; 
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
$headers .= "X-Priority: 1\r\n"; 
$headers .= "X-MSMail-Priority: High\r\n"; 
$headers .= "X-Mailer: My script Mailer\n";

mail($toemail, $subject, $message, $headers, "-f".$fromemail);

 

You do need to check that any variables you use that allow people to enter values into (ie, from a web page) are checked to ensure they only contain a single email address though - otherwise it quickly becomes very insecure.

Link to comment
Share on other sites

I am having 2 problems. One of which I have fixed.

 

This is what I have"

 

$fromname = "wayne";

$fromemail = "wayne@here.com";

 

$toname = "customer";

$toemail = "customer@there.com";

 

$subject = "subject of email";

 

$message = "Test message\n";

$message .= "\n";

$message .= "signed\n";

 

$headers = "From: $fromname <$fromemail>\r\n";

$headers .= "Reply-To: $fromname <$fromemail>\r\n";

$headers .= "To: $toname <$toemail>\r\n";

$headers .= "bcc: $fromname <$fromemail>\r\n";

$headers .= "MIME-Version: 1.0\r\n";

$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

$headers .= "X-Priority: 1\r\n";

$headers .= "X-MSMail-Priority: High\r\n";

$headers .= "X-Mailer: My script Mailer\n";

 

mail($toemail, $subject, $message, $headers, "-f".$fromemail);

 

 

I have noticed 2 problems when I run the script as instructed above.

 

 

The $toemail address is getting 2 emails. So I removed the $headers entry for the "To" field and now it is fixed (since the $toemail is also in the actual mail() command).

 

 

HOWEVER I get the mail to $toname bouncing back. This email address is working as it is on my day job email address (on a server not located at TCH if that means anything). I do get the mail at the bcc address (which is an acount on the TCH server running the script).

 

The error in the bounced mail is

unrouteable mail domain "there.com"

 

Any help is much appreciated.

 

 

Wayne

Link to comment
Share on other sites

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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