Kval Posted May 13, 2011 Share Posted May 13, 2011 Hello... I have a site that sends an email using the following code: mail($email,"Welcome to ohio-dui-laws.com","Hello ".$fname.",\n\nYour account on Ohio Dui Laws has been created.\nPlease login and fill out your profile details in order to have access to all the member content. \n\n\tUsername : ".$email." \n\tPassword : ".$_POST["password"]."\n\nThanks for joining http://Ohio-dui-laws.com"); Currently, when the recipient receives the email the From is defaulting to the server and looks like this: [email protected] What I would like is for the From in the email header to show [email protected]. Would you be so kind and add whatever I need to the above code so that it displays [email protected]? Thank you so much. Quote Link to comment https://forums.phpfreaks.com/topic/236338-add-from-field-in-php-email/ Share on other sites More sharing options...
fugix Posted May 13, 2011 Share Posted May 13, 2011 you'll want to add a headers parameter $headers = 'From: Birthday Reminder <[email protected]>' . "\r\n" just insert whatever email you want...so your mail() function will look like this now mail($email,"Welcome to ohio-dui-laws.com","Hello ".$fname.",\n\nYour account on Ohio Dui Laws has been created.\nPlease login and fill out your profile details in order to have access to all the member content. \n\n\tUsername : ".$email." \n\tPassword : ".$_POST["password"]."\n\nThanks for joining http://Ohio-dui-laws.com", '$headers'); Quote Link to comment https://forums.phpfreaks.com/topic/236338-add-from-field-in-php-email/#findComment-1215099 Share on other sites More sharing options...
Kval Posted May 14, 2011 Author Share Posted May 14, 2011 you'll want to add a headers parameter $headers = 'From: Birthday Reminder <[email protected]>' . "\r\n" just insert whatever email you want...so your mail() function will look like this now mail($email,"Welcome to ohio-dui-laws.com","Hello ".$fname.",\n\nYour account on Ohio Dui Laws has been created.\nPlease login and fill out your profile details in order to have access to all the member content. \n\n\tUsername : ".$email." \n\tPassword : ".$_POST["password"]."\n\nThanks for joining http://Ohio-dui-laws.com", '$headers'); Thank you my friend. Okay...$headers was displaying as full text in the body of the email. I change to double quotes: mail($email,"Welcome to ohio-dui-laws.com","Hello ".$fname.",\n\nYour account on Ohio Dui Laws has been created.\nPlease login and fill out your profile details in order to have access to all the member content. \n\n\tUsername : ".$email." \n\tPassword : ".$_POST["password"]."\n\nThanks for joining http://Ohio-dui-laws.com", "$headers"); Plus, sadly it still is not working. The header says: [email protected]. I did copy and past the <head> info: $headers = 'From: Ohio-DUI-LAWS/DUI Self Help Website <[email protected]>' . "\r\n" Any thoughts? Thank you again, Kevin Quote Link to comment https://forums.phpfreaks.com/topic/236338-add-from-field-in-php-email/#findComment-1215294 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.