Jump to content

$headers .= 'From: '.$name.'<'.$from.'>'."\n"; - Not working


nealec

Recommended Posts

Trying to send email to all users in db all works fine but it wont use my name or email. when i check inbox they are all from ****@cpanel42.uk2.net, i need it to look like,

 

From: My Name - [email protected]

<?php

$dbhost = '';
$dbuser = '';
$dbpass = '';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to mysql');

mysql_select_db("", $conn);

$name = "My Name";
$from = "[email protected]";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$headers .= 'From: '.$name.'<'.$from.'>'."\n";
$subject = "Subject";
$body = $message;

$query = mysql_query("SELECT email FROM users") or die(mysql_error());

while(list($email) = mysql_fetch_row($query)) {
mail($email, $subject, $body, $headers);
}

?> 

 

I can get it to use just my email if i add "-f [email protected]" but i really want to add my name

Link to comment
https://forums.phpfreaks.com/topic/254741-headers-from-namen-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.