elmas156 Posted September 26, 2008 Share Posted September 26, 2008 Hello everyone, I'm creating a mail function with some headers so that the email will display who the sender is but I'm having trouble putting variables in the header so that it will display the name and email address of the sender. Here's what I have: $myheaders .= 'Customer Name <[email protected]>' . "\r\n"; But I want to add a name and email variable. I can't get this to work the way I'm trying it. $myheaders .= '$name <$email>' . "\r\n"; What am I doing wrong? Link to comment https://forums.phpfreaks.com/topic/125904-solved-help-with-simple-mail-function/ Share on other sites More sharing options...
ratcateme Posted September 26, 2008 Share Posted September 26, 2008 $myheaders .= 'Customer Name <[email protected]>' . "\r\n"; looks to me like an invalid header Scott. Link to comment https://forums.phpfreaks.com/topic/125904-solved-help-with-simple-mail-function/#findComment-651064 Share on other sites More sharing options...
elmas156 Posted September 26, 2008 Author Share Posted September 26, 2008 $myheaders .= 'Customer Name <[email protected]>' . "\r\n"; looks to me like an invalid header Scott. The header works fine in this form, it's only when I attempt to add variables to make the customer name and email address dynamic when it gives me problems. Link to comment https://forums.phpfreaks.com/topic/125904-solved-help-with-simple-mail-function/#findComment-651066 Share on other sites More sharing options...
elmas156 Posted September 26, 2008 Author Share Posted September 26, 2008 actually this is the header that works... my mistake. $myheaders .= 'From: Customer Name <[email protected]>' . "\r\n"; Link to comment https://forums.phpfreaks.com/topic/125904-solved-help-with-simple-mail-function/#findComment-651067 Share on other sites More sharing options...
fanfavorite Posted September 26, 2008 Share Posted September 26, 2008 Try: $myheaders .= "From: " . $name . " <" . $email . ">" . "\r\n"; Make sure that you have your headers correct though. An example: $myheaders = "MIME-Version: 1.0\r\n"; $myheaders .= "Content-type: text/html; charset=iso-8859-1\r\n"; $myheaders .= "From: " . $name . " <" . $email . ">"; Link to comment https://forums.phpfreaks.com/topic/125904-solved-help-with-simple-mail-function/#findComment-651068 Share on other sites More sharing options...
elmas156 Posted September 26, 2008 Author Share Posted September 26, 2008 Yeah, I've got them all right, it's only the last one that's giving me problems. Link to comment https://forums.phpfreaks.com/topic/125904-solved-help-with-simple-mail-function/#findComment-651070 Share on other sites More sharing options...
elmas156 Posted September 26, 2008 Author Share Posted September 26, 2008 Awesome, it worked! Thanks for your help! Link to comment https://forums.phpfreaks.com/topic/125904-solved-help-with-simple-mail-function/#findComment-651072 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.