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: [email protected] \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 [email protected] for assistance.<br />";

        	return true;      }

Yeah

 

I am really looking for the code

 

:-)

 

http://www.w3schools.com/PHP/php_mail.asp

 

 

Try a dry run and do this:

 

mail(to,subject,message,Bbc:EMAILSHERE)

 

I'm not 100% sure that will work but it's worth a try ;)

<?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: [email protected] \r\n" . "Bcc: [email protected] \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 [email protected] for assistance.<br />";

        	return true;      }

?>

 

Try that

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.