0

here is my code....

$subject = "This is Subject";
$headers .= 'Content-type: text/html; charset=iso-8859-1';  
$to = '[email protected]';
$body = 'Mail Content Here';        
mail($to, $subject, $body, $headers);

but when i open this file it sends a mail to $to successfully but with wrong headers....and my hosting server default address i.e mars.myhosting.com, instead of [email protected] how can i fix that

1
  • you're using the concatenation operator for the 'headers' variable. What's the full value of the variable? Also, have you enabled trace on the mail server, or used a network sniffer to see exactly what's actually being sent? Commented Dec 29, 2009 at 6:56

2 Answers 2

3

Look at this from php.net

$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: Webmaster <[email protected]>' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

Add the from header

Sign up to request clarification or add additional context in comments.

1 Comment

should it send a html headers or not
2

Here is what I would do via PHP:

<?PHP

$to = '[email protected]';
$subject = 'desired subject';
$message = 'desired message';
$headers = 'From: [email protected]' . "\r\n" .
   'Reply-To: [email protected]' . "\r\n" .
   'Return-Path: [email protected]' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);

?>

I hope that helps some :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.