PHPファイルで、2つの異なるメールを2つの異なるIDに送信する必要があります。以下に示すように、このような2つの変数を使用すると機能しませんでした。
require 'PHPmailer/class.phpmailer.php';
/* First Email*/
$email = new PHPMailer();
$email->From = 'admin@mywebsite.com';
$email->FromName = 'My Webisite';
$email->Subject = 'Subject of first email';
$email->Body = 'Body of the message to first person';
$email->AddAddress( 'to first person' );
$file_to_attach = 'path of the file';
$email->AddAttachment( $file_to_attach, '' );
$email->Send();
/* Second Email*/
require 'PHPmailer/class.phpmailer.php';
$confirm = new PHPMailer();
$confirm-> From = 'noreply@mywebsite.com';
$confirm-> FromName = 'Admin @ MyWebsite';
$confirm-> Subject = 'Subject of second email';
$confirm-> Body = 'Body of second email';
$confirm-> AddAddress('Email ID of second person');
$confirm->Send();
しかし、同じ変数を2回使用すると、以下に示すように機能します
require 'PHPmailer/class.phpmailer.php';
/* First Email*/
$email = new PHPMailer();
/* Same as above*/
$file_to_attach = 'path of the file';
$email->AddAttachment( $file_to_attach, '' );
$email->Send();
/* Second Email*/
$email-> From = 'noreply@mywebsite.com';
$email-> FromName = 'Admin @ MyWebsite';
$email-> Subject = 'Subject of second email';
$email-> Body = 'Body of second email';
$email-> AddAddress('Email ID of second person');
$email->Send();
しかし問題は、添付ファイルを両方の電子メール ID に送信していることです。添付ファイルを 2 番目の ID に送信しない方法を教えてください。