0

さて、私はこのコードを手に入れました、それは動作しますが、PHPMailerのすべてのループを設定する必要があります。それが良い場合はidkですが、すべてのループを設定しないと変更されません。

foreach($this->users as $v)
{   
    $this->phpmailer = new PHPMailer();

    $this->phpmailer->IsSMTP();
    $this->phpmailer->SMTPAuth = true;
    $this->phpmailer->SMTPSecure = 'ssl';

    $this->phpmailer->Host = 'smtp.gmail.com';
    $this->phpmailer->Port = 465;

    $this->phpmailer->ClearAllRecipients();
    $this->phpmailer->AddAddress($v['email']);

    $this->phpmailer->Username = $v['email_user'];
    $this->phpmailer->Password = $v['email_pass'];

    $this->phpmailer->From = $v['email_user'];
    $this->phpmailer->FromName = $v['email_name'];

...

動作しますが、ループごとに PHPMailer を設定していますが、そうすると:

$this->phpmailer = new PHPMailer();

$this->phpmailer->IsSMTP();
$this->phpmailer->SMTPAuth = true;
$this->phpmailer->SMTPSecure = 'ssl';

$this->phpmailer->Host = 'smtp.gmail.com';
$this->phpmailer->Port = 465;

foreach($this->users as $v)
{       
    $this->phpmailer->ClearAllRecipients();
    $this->phpmailer->AddAddress($v['email']);

    $this->phpmailer->Username = $v['email_user'];
    $this->phpmailer->Password = $v['email_pass'];

    $this->phpmailer->From = $v['email_user'];
    $this->phpmailer->FromName = $v['email_name'];

...

それは機能しますが、 from はすべてのループを変更しません。

4

2 に答える 2

0

私はあなたのための解決策を持っていませんが、PHPMailer での経験を共有したいと思いました: メールが同じで受信者が異なる場合でも、送信するメールごとにまったく新しいオブジェクトを作成して、必要な結果を得る必要がありました。 .

于 2012-10-01T02:25:57.453 に答える
0

言いにくい。エラー報告はすべてのエラーを表示するように設定されていますか? phpMailer から何か失敗していますか? これはありそうもありませんが、実行中のオブジェクト ループがログを汚染し、スクリプトが正しく実行されないという同様の問題を見たことがあります。

これが役立つことを願っています。あなたが見つけたものを教えてください。

于 2012-10-01T02:43:50.083 に答える