jmfillman Posted June 13, 2010 Share Posted June 13, 2010 I have 2 issues with the script below: 1. If I pass in the e-Mail to send the message to, the message doesn't send. 2. How do I structure the message to send both the text and the $Password value? public function sendPass($eMail, $Password) { $to = $eMail; $subject = 'Password Request'; $from = '[email protected]'; $message = 'Your password was requested from our website. Your password is $Password'; if (mail($to, $subject, $message, "From: $from")) { echo "Password Sent"; } else { echo "Mail Send Failure - Message Not Sent"; } } Link to comment https://forums.phpfreaks.com/topic/204613-mail-message-formatting/ Share on other sites More sharing options...
jmfillman Posted June 13, 2010 Author Share Posted June 13, 2010 Bump...Anybody?? I need help to figure this out! Link to comment https://forums.phpfreaks.com/topic/204613-mail-message-formatting/#findComment-1071508 Share on other sites More sharing options...
mrMarcus Posted June 13, 2010 Share Posted June 13, 2010 change: $message = 'Your password was requested from our website. Your password is $Password'; to: $message = "Your password was requested from our website. Your password is {$Password}"; Link to comment https://forums.phpfreaks.com/topic/204613-mail-message-formatting/#findComment-1071530 Share on other sites More sharing options...
rwwd Posted June 13, 2010 Share Posted June 13, 2010 Hi there jmfillman, try this:- public function sendPass($eMail, $Password) { $subject = "Password Request"; $headers = "[email protected]"; $headers .= "content-type: text/plain; charset=UTF-8\r\n"; $message = "Your password was requested from our website. Your password is ".$Password; if (mail($to, $subject, $message, $headers)) { echo "Password Sent"; } else { echo "Mail Send Failure - Message Not Sent"; } } I always find it easier to use double quotes when constructing a string attached to a var, but its down to preference at the end of the day That should at least get the message going, there are more efficient ways of doing this, but for now, just get the mail going! Cheers, Rw Link to comment https://forums.phpfreaks.com/topic/204613-mail-message-formatting/#findComment-1071583 Share on other sites More sharing options...
jmfillman Posted June 14, 2010 Author Share Posted June 14, 2010 Thanks Rw, that was the solution! Link to comment https://forums.phpfreaks.com/topic/204613-mail-message-formatting/#findComment-1071703 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.