Jump to content

cynlewman

New Members
  • Posts

    4
  • Joined

  • Last visited

cynlewman's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. So, is this what I should remove? Before Edit if(empty($recipients)){ $recipients = $to; if(!empty($cc)){ $recipients.= "," .$cc; } if(!empty($bcc)){ $recipients.= "," .$bcc; } } After Edit if(empty($recipients)){ $recipients = $to; }
  2. Can you please be more specific? Is this the exact code I should delete? if(empty($recipients)){ $recipients = $to; if(!empty($cc)){ $recipients.= "," .$cc; } if(!empty($bcc)){ $recipients.= "," .$bcc; } }
  3. So should I delete the following? Sorry for being such a newbie. Someone else wrote the code and now I'm trying to correct it. if(!empty($bcc)){ $recipients.= "," .$bcc; }
  4. I need help with PHP code that sends automated email receipts to customers. The problem is the customer can see the bcc email address. Can you help me with what code is needed to make the bcc field blind to customers? <?php //change the email parameters as required. //$ccEmail="xxx@xx.com"; $formName="xxxx"; //set the form name as required. $fromEmail="xxxx@xxxx.com"; //set the form email as required. $subject="Your Order Receipt"; //set the subject of the email. $bccEmail="xxxx@xxxx.com,xxxx@xxxx.com"; define("ROOT_PATH","/path/xxxx.com/web/content/"); $fields_string = ""; foreach($_POST as $key=>$value) { if($fields_string != "") { $fields_string .= "&"; } $fields_string .= $key."=".urlencode($value); } $stringval=rtrim($fields_string); include_once("email_format.php"); //uncomment one of the two lines below to toggle test and live mode. $toEmail=$payer_email; //live mode - uncomment to send to buyers email //$toEmail="infoxxx@xxx.com"; // test mode - uncomment to send to infoxxx@xxx.com for testing if($strTemplate!=""){ WriteLogFile($stringval); SendEmail(); //echo $strTemplate; } function WriteLogFile($stringname){ $today = date("F j, Y, g:i a"); $myFile = ROOT_PATH . "website/xxxx/log/log.txt"; if(file_exists($myFile)){ $fp = fopen($myFile, 'a') or die("can't open file"); fwrite($fp,$stringname . "\n" . $today . "\n"); fclose($fp); } return true; } function SendEmail(){ global $formName,$toEmail,$ccEmail,$bccEmail,$strTemplate,$subject,$fromEmail; require_once "Mail.php"; //$from = "xx@xxx.com"; $from = $fromEmail; $to = $toEmail; $body = $strTemplate; $cc=$ccEmail; $bcc=$bccEmail; /*$host = "smtp.emailsrvr.com"; $username = "XXXXX"; $password = "XXXXX"; $host = "smtp.emailsrvr.com"; $username = "xxxxx@xxxxx.com"; $password = "xxxxxx"; */ $host = "smtp.mailgun.org"; $username = "xxxxxx@xxxxx.com"; $password = "xxxxxxxxxx"; if(!empty($cc) && !empty($bcc)){ $headers = array ('From' => $formName . '<' . $from . '>', 'To' => $to, 'Cc' => $cc, 'Bcc' => $bcc, 'Subject' => $subject, 'Content-type'=> 'text/html', 'charset'=> 'iso-8859-1'); } if(empty($cc) && !empty($bcc)){ $headers = array ('From' => $formName . '<' . $from . '>', 'To' => $to, 'Bcc' => $bcc, 'Subject' => $subject, 'Content-type'=> 'text/html', 'charset'=> 'iso-8859-1'); } if(empty($bcc) && !empty($cc)){ $headers = array ('From' => $formName . '<' . $from . '>', 'To' => $to, 'Cc' => $cc, 'Subject' => $subject, 'Content-type'=> 'text/html', 'charset'=> 'iso-8859-1'); } $smtp = Mail::factory('smtp', array ('host' => $host, 'port' => 587, 'auth' => true, 'username' => $username, 'password' => $password)); if(empty($recipients)){ $recipients = $to; if(!empty($cc)){ $recipients.= "," .$cc; } if(!empty($bcc)){ $recipients.= "," .$bcc; } } echo $recipients; //die($recipients); $mail = $smtp->send($recipients, $headers, $body); if (PEAR::isError($mail)) { //echo("<p>" . $mail->getMessage() . "</p>"); WriteLogFile($mail->getMessage()); die($mail->getMessage()); } else { //echo "Email sent through Server SMTP to " . $recipients; WriteLogFile("Email sent through Server SMTP to " . $recipients); return true; } } ?>
×
×
  • 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.