0

Can anyone help me with the mail function? The mail is sending with the code below:

//  Set up Email Parameters
    $from = "Condolence Submission";
    $subject = "Condolence";

// To send HTML mail, set the Content-type header. */
    $headers = 'MIME-Version: 1.0' . "\r\n" .
			'Content-type: text/html; charset=iso-8859-1' .  \r\n" .
                       'To: Tara <tmv105@gmail.com>' . "\r\n" .
                       'From: $from' . "\r\n" .
                       'Cc: greatfultobe@yahoo.com' . "\r\n" .
                       'Bcc: talong@netscape.com' . "\r\n" .
                       'X-Mailer: PHP/' . phpversion();
 
//  Send Email
mail($to,$subject,$message,$headers);

...but the "From" in the email is showing as "$from" and not the value I have assigned the variable. I tried do this for the "From"

'From: Condolence Submission' . "\r\n" .

and I get (unknown sender) in the "From" of my email.

1
Contributor
1
Reply
3
Views
8 Years
Discussion Span
Last Post by tmv105
0

I actually figured it out. If I place an email address in the from, it works. I suppose that PHP mail() requires an email address here. Here is what I did:

//  Set up Email Parameters
    $from = $_POST['email'];
    $subject = "Condolence";
	 
	// To send HTML mail, set the Content-type header. */
	$headers = 'MIME-Version: 1.0' . "\r\n" .
				'Content-type: text/html; charset=iso-8859-1' . "\r\n" .

	/* additional headers */
	//$headers .= "To: Michael <diehlfhi@aol.com>, Tara <tmv105@gmail.com>\r\n";
	'To: Tara <tmv105@gmail.com>' . "\r\n" .
	//'From: condolence@deihl.com' . "\r\n" .
	'From:'. $from . "\r\n" .
	'Cc: greatfultobe@yahoo.com' . "\r\n" .
	'Bcc: talong@netscape.com' . "\r\n" .
	'X-Mailer: PHP/' . phpversion();
     
    //  Send Email
    mail($to,$subject,$message,$headers);

Both ways work...either hard coding an email into the "From" or filling the value in from a variable set from data on my form.

Thought that I would give an attempt of an explanation to any who might wanna know. :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.