Jump to content

Add from field in PHP Email


Kval

Recommended Posts

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.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/236338-add-from-field-in-php-email/
Share on other sites

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');

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

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.