Jump to content

[SOLVED] How do I add a blind copy to an email script?


Conjurer

Recommended Posts

I have some code set up to mail out a reset password.  For testing mode I want to add a blind copy to myself but am not sure how to add that to the script.

 

Here is the guts of the existing code:

 

   
/*I connected successfully and an email address exists in the mysql database so now I fetch it.*/

$row = $result->fetch_object();
      $email = $row->email;   /* Sets variable equal to the email */

      $from = "From: support@XYZ.com \r\n";
      $mesg = "Your password for the XYZ Member directory has been changed. \r\n"
  				."You can login to the membership directory at http://www.XYZ.com/Directory/index.php5 \r\n\r\n"
				."Your username is: $username \r\n"
				."Your new password is: $password\r\n\r\n"
              ."You can either keep this password or change it to one you preferr the next time you log in. "
		  ."To change it, once you log in click on the \"Change Password\" button.\r\n";
      
    /* so here is where I put the email together from the variables.  How can I hard code a blind copy into the if statement behind the $email variable? */
  
      if (mail($email, 'XYZ login information', $mesg, $from))    
  {		echo "Your new password has been e-mailed to you at $email.<br />";
		echo "If you no longer have access to the $email e-mail account, please contact our webmaster at info@XYZ.com for assistance.<br />";

        	return true;      }

Link to comment
Share on other sites

<?php

/*I connected successfully and an email address exists in the mysql database so now I fetch it.*/

$row = $result->fetch_object();
      $email = $row->email;   /* Sets variable equal to the email */

      $from = "From: support@XYZ.com \r\n" . "Bcc: webmaster@example.com \r\n";
      $mesg = "Your password for the XYZ Member directory has been changed. \r\n"
  				."You can login to the membership directory at http://www.XYZ.com/Directory/index.php5 \r\n\r\n"
				."Your username is: $username \r\n"
				."Your new password is: $password\r\n\r\n"
              ."You can either keep this password or change it to one you preferr the next time you log in. "
		  ."To change it, once you log in click on the \"Change Password\" button.\r\n";
      
    /* so here is where I put the email together from the variables.  How can I hard code a blind copy into the if statement behind the $email variable? */
  
      if (mail($email, 'XYZ login information', $mesg, $from))    
  {		echo "Your new password has been e-mailed to you at $email.<br />";
		echo "If you no longer have access to the $email e-mail account, please contact our webmaster at info@XYZ.com for assistance.<br />";

        	return true;      }

?>

 

Try that

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.