Jump to content

Mail Message Formatting


jmfillman

Recommended Posts

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

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

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.