TotalChoice Hosting Family Forums: Php Mail Script Needed - TotalChoice Hosting Family Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Php Mail Script Needed my script no longer allowed

#1 User is offline   wayne Icon

  • Family Friend
  • PipPip
  • Group: Members
  • Posts: 80
  • Joined: 02-May 04

Posted 14 December 2005 - 11:30 AM

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.

#2 User is offline   TCH-Bruce Icon

  • Lead Forum Moderator
  • PipPipPipPip
  • Group: Admins
  • Posts: 21,239
  • Joined: 11-August 03

Posted 14 December 2005 - 12:51 PM

Use the -f switch to tell sendmail to set the envelope address:

-f email@address.com
Bruce Richards
Lead Forum Moderator
TotalChoice Hosting, L.L.C.
Webhosting by Total Choice Web Hosting - General Support Forum

I am the Lead Forum Moderator. While I can assist in answering most of your hosting related questions, I am unable to answer questions about specifics relating to your account such as billing and server related issues. Should you need assistance in these areas, please contact our Help Desk or our many other options. Another good place to find answers is with our help pages, tutorials and movie tutorials.

#3 User is offline   wayne Icon

  • Family Friend
  • PipPip
  • Group: Members
  • Posts: 80
  • Joined: 02-May 04

Posted 14 December 2005 - 01:09 PM

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?

#4 User is offline   TCH-Bruce Icon

  • Lead Forum Moderator
  • PipPipPipPip
  • Group: Admins
  • Posts: 21,239
  • Joined: 11-August 03

Posted 14 December 2005 - 01:22 PM

mail($contactemail, $subject, $message, $headers, "-f".$myemail);

Bruce Richards
Lead Forum Moderator
TotalChoice Hosting, L.L.C.
Webhosting by Total Choice Web Hosting - General Support Forum

I am the Lead Forum Moderator. While I can assist in answering most of your hosting related questions, I am unable to answer questions about specifics relating to your account such as billing and server related issues. Should you need assistance in these areas, please contact our Help Desk or our many other options. Another good place to find answers is with our help pages, tutorials and movie tutorials.

#5 User is offline   TCH-Andy Icon

  • Immediate Family
  • PipPipPipPip
  • Group: Staff
  • Posts: 4,729
  • Joined: 14-January 03

Posted 14 December 2005 - 01:27 PM

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

#6 User is offline   wayne Icon

  • Family Friend
  • PipPip
  • Group: Members
  • Posts: 80
  • Joined: 02-May 04

Posted 14 December 2005 - 01:49 PM

Thanks for the speedy responses.
I will edit my scripts and yes I check the email addresses.


Wayne

#7 User is offline   wayne Icon

  • Family Friend
  • PipPip
  • Group: Members
  • Posts: 80
  • Joined: 02-May 04

Posted 14 December 2005 - 07:58 PM

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

#8 User is offline   TCH-Andy Icon

  • Immediate Family
  • PipPipPipPip
  • Group: Staff
  • Posts: 4,729
  • Joined: 14-January 03

Posted 15 December 2005 - 02:44 AM

without the real domain name it's difficult to investigate.

Although we don't provide coding support via the help desk, open a ticket and we'll take a quick look at why it's failing to that domain.
Andy Beckett

#9 User is offline   wayne Icon

  • Family Friend
  • PipPip
  • Group: Members
  • Posts: 80
  • Joined: 02-May 04

Posted 15 December 2005 - 08:11 AM

actually it is any domain that is outside my server. ie I have tried hotmail.com, yahoo.ca and all fail

Seems that if I make the address my own domain, I get the mail fine.

#10 User is offline   TCH-Bruce Icon

  • Lead Forum Moderator
  • PipPipPipPip
  • Group: Admins
  • Posts: 21,239
  • Joined: 11-August 03

Posted 15 December 2005 - 09:15 AM

I have no idea why you are getting errors Wayne. I copied and pasted your script into a test PHP file changed the email addresses to my own and it worked perfectly.
Bruce Richards
Lead Forum Moderator
TotalChoice Hosting, L.L.C.
Webhosting by Total Choice Web Hosting - General Support Forum

I am the Lead Forum Moderator. While I can assist in answering most of your hosting related questions, I am unable to answer questions about specifics relating to your account such as billing and server related issues. Should you need assistance in these areas, please contact our Help Desk or our many other options. Another good place to find answers is with our help pages, tutorials and movie tutorials.

#11 User is offline   wayne Icon

  • Family Friend
  • PipPip
  • Group: Members
  • Posts: 80
  • Joined: 02-May 04

Posted 15 December 2005 - 01:14 PM

Bruce

I opened a help desk ticket and they fixed something on the server end. All is now working with the -f switch.

Thanks all for your advice, as usual service here at TCH ROCKS!!

#12 User is offline   TCH-Bruce Icon

  • Lead Forum Moderator
  • PipPipPipPip
  • Group: Admins
  • Posts: 21,239
  • Joined: 11-August 03

Posted 15 December 2005 - 01:54 PM

Glad it's working. :thumbup1:
Bruce Richards
Lead Forum Moderator
TotalChoice Hosting, L.L.C.
Webhosting by Total Choice Web Hosting - General Support Forum

I am the Lead Forum Moderator. While I can assist in answering most of your hosting related questions, I am unable to answer questions about specifics relating to your account such as billing and server related issues. Should you need assistance in these areas, please contact our Help Desk or our many other options. Another good place to find answers is with our help pages, tutorials and movie tutorials.

#13 User is offline   TCH-Rob Icon

  • Help Desk Manager
  • PipPipPipPip
  • Group: Members
  • Posts: 7,818
  • Joined: 11-March 03

Posted 15 December 2005 - 03:32 PM

Alright Wayne, nice to see you are on the road again.

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users