Forum Moderators: coopster

Message Too Old, No Replies

email in plain and html including php variables

         

steve_dr

4:28 pm on Feb 19, 2010 (gmt 0)

10+ Year Member



hellow,
i want to generate an e-mail including a new password for a user but want to generate a double formatting style (plain text or html).
In the email I want to display some variable values.
However, this is not working.
Does someone sees what i am doing wrong?
thanks a lot!
steve

*****START OF CODE**********

$user_email = mysql_real_escape_string($_POST['user_email']);
$website='http://mywebsite.be';
$link_website = '<a href="'.$website.'">login page</a>';
$helpdesk = 'helpdesk@mywebsite.be';
$link_helpdesk = '<a href="mailto:'.$helpdesk.'?subject=Password phishing">administrator</a>';

$random_hash = md5(date('r', time()));
$headers = "From: \"Member Registration\" <auto-reply@$host>";
$headers .= "\r\nContent-Type: multipart/alternative;
boundary=\"PHP-alt-".$random_hash."\"";
ob_start();
?>
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Here are your new password details:
User e-mail: <?php $user_email ?>
Password: <?php $new ?>

If you didn't request that your password be reset, please contact <?php $helpdesk ?>.

Administrator
______________________________________________________
THIS IS AN AUTOMATED RESPONSE.
***DO NOT REPLY TO THIS EMAIL****

--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Here are your new password details: < /br>
User e-mail: <?php $user_email ?> < /br>
Password: <?php $new ?> < /br>

Go back to the <?php $link_website ?>.

If you didn't request that your password be reset, please contact the $link_helpdesk.

Administrator
$host_upper
______________________________________________________
THIS IS AN AUTOMATED RESPONSE.
***DO NOT REPLY TO THIS EMAIL****

--PHP-alt-<?php echo $random_hash; ?>--
<?php
$message = ob_get_clean();

$mail_sent = @mail( $user_email, "[SMP] Reset password", $message, $headers );

$msg ="Your password has been reset and a new password has been sent to your email address.";


*****END OF CODE**********


*****START OF OUTPUT**********

Here are your new password details:
User e-mail: Password:
If you didn't request that your password be reset, please contact .
Content-Transfer-Encoding: 7bit

Administrator
______________________________________________________
THIS IS AN AUTOMATED RESPONSE.
***DO NOT REPLY TO THIS EMAIL****

Content-Transfer-Encoding: 7bit

Here are your new password details: < /br> User e-mail: < /br>
Password: < /br>

Go back to the .

If you didn't request that your password be reset, please contact the $link_helpdesk.

Administrator
$host_upper
______________________________________________________
THIS IS AN AUTOMATED RESPONSE.
***DO NOT REPLY TO THIS EMAIL****

--PHP-alt-b4e0ea0b7a012c2b57457ea2b4966cec--

-------

*****END OF OUTPUT**********

So I got one email with both outputs and no variables at all :-(

Matthew1980

6:16 pm on Feb 19, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there Steve_dr,

Welcome to the forum, on a quick glance there are only a few errors that I can spot:-

Here are your new password details:
User e-mail: <?php echo $user_email; ?>
Password: <?php echo $new; ?>


Same on the Admin part too, also:-


Go back to the <?php echo $link_website; ?>.


and:-


If you didn't request that your password be reset, please contact <?php echo $helpdesk; ?>.


Other than that I can't see anything on a quick read of this, try that and see what you get.

Cheers,

MRb