nealec Posted January 10, 2012 Share Posted January 10, 2012 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 More sharing options...
laffin Posted January 10, 2012 Share Posted January 10, 2012 Proper format should be 'My Name' <[email protected]> Link to comment https://forums.phpfreaks.com/topic/254741-headers-from-namen-not-working/#findComment-1306232 Share on other sites More sharing options...
nealec Posted January 10, 2012 Author Share Posted January 10, 2012 Proper format should be 'My Name' <[email protected]> Could you please explain or show me what you mean, its taken me almost 3 days just to get this far, im new to scripting or coding. Link to comment https://forums.phpfreaks.com/topic/254741-headers-from-namen-not-working/#findComment-1306237 Share on other sites More sharing options...
laffin Posted January 10, 2012 Share Posted January 10, 2012 $headers .= "From: '$name' <$from>\n"; Link to comment https://forums.phpfreaks.com/topic/254741-headers-from-namen-not-working/#findComment-1306239 Share on other sites More sharing options...
nealec Posted January 10, 2012 Author Share Posted January 10, 2012 $headers .= "From: '$name' <$from>\n"; Ok i gave it a go but im still getting the email from ****@cpanel42.uk2.net instead of, My Name - [email protected] Link to comment https://forums.phpfreaks.com/topic/254741-headers-from-namen-not-working/#findComment-1306240 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.