0

I have tried to send mail from my new php website. Mail is delivering but I'm not getting the subject and From fields correctly.

<?php
define('incall', true);

if(!@include_once('config.php'))
{
    header('HTTP/1.0 404 Not Found');
    exit;
}

$to=$_POST['to'];
$message    = str_replace('{link}', $download_path.$_POST['filename'].'.mp3', $email_body);
$headers  = "From: ".$emailfrom_name." <".$emailfrom_address.">\r\n"
                 ."Return-Path: ".$emailfrom_address."\r\n";
$subject=$_POST['subject']

if(mail($to, $subject, $message, $headers))header("location:mailsent.php");

exit('Error! Can not be send.');
?>

Could you please check and answer ?

4
  • first echo the values $_POST['subject'] and $emailfrom_name and see whether you are getting the values here and not Commented Mar 12, 2011 at 12:30
  • 1
    What do you mean "not getting correctly"? What exactly do you get, and what do you expect to get? Commented Mar 12, 2011 at 12:35
  • I'm getting the mail. But the From is found to be 'unknown' :( Commented Mar 12, 2011 at 12:36
  • Thanks everyone. I got the problem got solved :) Commented Mar 12, 2011 at 12:55

3 Answers 3

1

Are you sure this is not a typo ??

$message    = str_replace('{link}', $download_path.$_POST['filename'].'.mp3', $email_body);
$headers  = "From: ".$emailfrom_name." <".$emailfrom_address.">\r\n"
                 ."Return-Path: ".$emailfrom_address."\r\n";

$subject=$_POST['subject']

if(mail($to, $subject, $message, $headers))header("location:mailsent.php");

semi colon missing

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

1 Comment

Thanks. Problem was in the "$headers = "From: ".$emailfrom_name." <".$emailfrom_address.">\r\n" ."Return-Path: ".$emailfrom_address."\r\n";"
0

I built a class for this - you can get it at: http://www.kaiesh.com/65/sending-html-composite-email-in-php-using-objects

Hope that helps!

Comments

0

Did you try using just "\n" instead of "\r\n" in the $headers string?

Comments

Your Answer

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