views:

36

answers:

1

Hello, I have a php file that I am trying to send the output in a email using the php mail function (PHPMailer is not an option as the server I am working restricts their SMTP server). The code for the mail function is

$to = "[email protected]";
$subject = "Outdoor Grill Service Request";
ob_start();
require 'grill-form.php';
$body = ob_get_clean();
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers = "From: [email protected]\n";
mail($to,$subject,$body,$headers);
echo "Mail sent to $to";

grill-form.php is a php file that contains a html file that has tables that are populated with php variable from a form. This worked perfectly using PHPMailer but once I migrated over to standard php mail is got "screwy".

The issue I am running into is when the email sends I am getting raw HTML code and not the output of the grill-form.php (a styled table with values). I have little knowledge with the php mail function so I might be missing something stupid.

Was wondering what I am doing wrong. Thank you in advance for you help you people are the best.

A: 

Assuming that's your actual code, you're overwriting the $headers variable with the third declaration, not appending to what you have. The Content-type header is never making it in.

PHPMailer does support SMTP, by the way--what exactly do you mean by "restricts their SMTP server"? (Here's an example: http://phpmailer.worxware.com/index.php?pg=examplebsmtp)

Michael Louis Thaler
That missing period was exactly my problem. I can't believe I missed that. Thank you. As far as the SMTP server goes I cannot explain it. I wrote the original function using PHPMailer and it worked fine on my machine (Apache) I was able to sent SMTP emails through my comcast, hotmail, and gmail account. However once I put it on their server (Linux), I kept getting a SMTP error 111 "Connection Rejected". I tried every port I could find, then I tried to use my gmail account again and same 111 error. After talking to tech support they said it was most likely their server and some firewall issue.
Chris