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 - my@email.co.uk <?php $dbhost = ''; $dbuser = ''; $dbpass = ''; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db("", $conn); $name = "My Name"; $from = "my@email.co.uk"; $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 my@email.co.uk" but i really want to add my name Quote Link to comment Share on other sites More sharing options...
laffin Posted January 10, 2012 Share Posted January 10, 2012 Proper format should be 'My Name' <my@email.com> Quote Link to comment Share on other sites More sharing options...
nealec Posted January 10, 2012 Author Share Posted January 10, 2012 Proper format should be 'My Name' <my@email.com> 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. Quote Link to comment Share on other sites More sharing options...
laffin Posted January 10, 2012 Share Posted January 10, 2012 $headers .= "From: '$name' <$from>\n"; Quote Link to comment 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 - my@email.co.uk Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.