phpmailを使用して別の人に別の画像を送信するメールサービスを作成しています.必要に応じてメールと添付ファイルを送信できますが、メールの本文に埋め込み画像を動的に追加する場合. 私は成功を収めることができません。
<?php
require_once('class.phpmailer.php');
// multiple recipients
$to = $arr['Contact.Email']; // note the comma
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
try{
$mail->SetFrom($arr['Contact.Email'], 'First Last');
$mail->AddAddress($arr['Contact.Email'], 'John Doe');
$mail->Subject = 'PHPMailer Test';
$mail->AddEmbeddedImage($arr['ContactId'].'.png', 'my-attach');
$mail->Body = 'Your <b>HTML</b> with an embedded Image: <img src=cid:my-attach\'> Here is an image!';
$mail->AddAttachment($arr['ContactId'].".png"); // this is a regular attachment (Not inline)
$mail->Send();
echo "Message Sent OK<p></p>\n";
}
catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
}
catch (Exception $e) {
echo $e->getMessage();
}
?>
1つの画像を埋め込むことはできますが、別のユーザーに別の画像を送信しようとするとエラーが発生します.どこでも検索しましたが、満足のいく答えが得られませんでした. どんな助けでも大歓迎です。