单独向所有

时间:2018-06-18 13:37:31

标签: php email phpmailer

我允许用户以逗号分隔输入多封电子邮件。我正在接收这些电子邮件并向他们发送电子邮件。想发送电子邮件给密送。

我想单独发送电子邮件,但是here is the screenshot

我的PHP代码是:

 $Email = new PHPMailer;
            $Email->IsSMTP(); 
            $Email->Host = "mail.cliqueipet.com.br"; 
            $Email->SMTPAuth = false; 
            $Email->IsHTML(true);
            $Email->Username = "xxxx"; 
            $Email->Password = "xxxx";
            $Email->SMTPSecure = "tls";
            //$Email->SMTPDebug = 2;
            $Email->From     = "convites@xxx.com.br";


            $Email->CharSet  = "UTF-8";
            $Email->FromName = $Nome . " - Festa na Vila das Pitangas";
     //here is i am adding address      
  for($i=0; $i<count($email); $i++):
                $Email->AddAddress($email[$i]);
            endfor; 
            $Email->Port = 587;
            $Email->Subject = " Convite para festa de $Nome na Vila das Pitangas. ";

2 个答案:

答案 0 :(得分:1)

您必须使用{% extends "base.html" %} {% block navbar %} <h1>Register</h1> <form action="" method="post"> {{ form.hidden_tag() }} <p> {{ form.username.label }}<br> {{ form.username(size=32) }}<br> {% for error in form.username.errors %} <span style="color: red;">[{{ error }}]</span> {% endfor %} </p> <p> {{ form.email.label }}<br> {{ form.email(size=64) }}<br> {% for error in form.email.errors %} <span style="color: red;">[{{ error }}]</span> {% endfor %} </p> <p> {{ form.password.label }}<br> {{ form.password(size=32) }}<br> {% for error in form.password.errors %} <span style="color: red;">[{{ error }}]</span> {% endfor %} </p> <p> {{ form.password2.label }}<br> {{ form.password2(size=32) }}<br> {% for error in form.password2.errors %} <span style="color: red;">[{{ error }}]</span> {% endfor %} </p> <p>{{ form.submit() }}</p> </form> {% endblock %} 功能

让我们说电子邮件保存为分隔的字符串;彼此之间(您需要遍历它们并使用addBCC函数将每封电子邮件添加到BCC)

addBCC

有关详细信息,请阅读PHPMailer documentation

答案 1 :(得分:0)

$toEmails = array('xyz@gmail.com','abc@gmail.com');    
for($i=0; $i<count($toEmails); $i++):
       $Email = new PHPMailer;
       $Email->IsSMTP(); 
       $Email->Host = "mail.cliqueipet.com.br"; 
       $Email->SMTPAuth = false; 
       $Email->IsHTML(true);
       $Email->Username = "xxxx"; 
       $Email->Password = "xxxx";
       $Email->SMTPSecure = "tls";
       //$Email->SMTPDebug = 2;
       $Email->From     = "convites@xxx.com.br";


       $Email->CharSet  = "UTF-8";
       $Email->FromName = $Nome . " - Festa na Vila das Pitangas";
       $mail->addAddress($toEmails[$i]);
       $mail->Subject  = 'Convite para festa de $Nome na Vila das Pitangas.';
       $mail->Body     = '<your mail body here>';
       if(!$mail->send()) {
              echo 'Message was not sent.';
              echo 'Mailer error: ' . $mail->ErrorInfo;
       } else {
              echo 'Message has been sent.';
       }
    endfor;  //this should end when ur first email sent 


    This should work will send 1 mail at a time in the loop.