开发者

PHPMailer tweek

开发者 https://www.devze.com 2023-03-13 15:04 出处:网络
Hello i need help on PHPMailer here is my code : $message = \'main message\'; $bccmessage = \'BCC Message\';

Hello i need help on PHPMailer here is my code :

    $message = 'main message';
            $bccmessage = 'BCC Message';
            include  '../inc/class.phpmailer.php';

                    $mail = new PHPMailer();
                    $mail->IsSMTP();
                    $mail->IsHTML(true);
                    $mail->CharSet = "UTF-8";
                    $mail->Host = "smtphost";
                    $mail->SMTPAuth = true;
                    $mail->Username = "email@domain.com";
                开发者_如何学运维    $mail->Password = "xxxxxx";
                    $mail->From = "email@domain.com";
                    $mail->FromName = "foo.com";
                    $mail->AddAddress($mainemail);
                $mail->AddBCC($bccemail);
                                    $mail->AddBCC($bccemail);
                    $mail->Subject = "Subject";
                    $mail->Body = "$message";
                    if(!$mail->Send())
                {
                    echo '<pre>Error: '.$mail->ErrorInfo.'</pre>';
                    exit;
                } else {
              //Display result 
                echo '<div class="success">message Sent</div>';
                }

My question is how can i manage that the "AddAddress" get $message and the "AddBCC" get the $bccmessage message.


You will have to send 2 separate emails to accomplish that.

You could do something like:

$oMail->Body = $sToMessage;
$oMail->addAddress($sToEmail);
$oMail->send();

// clear
$oMail->ClearAddresses();

$oMail->Body = $sBccMessage;
$oMail->addAddress($sBccEmail);
$oMail->send();

But I'd have to advice against it. You would do better to wrap the email sending in an function - and calling it twice with different parameters.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号