PHPMailerを使い下記のようにメールを送信しようとしたのですが文字化けしてしまいました。
php
1use PHPMailer\PHPMailer\PHPMailer; 2use PHPMailer\PHPMailer\Exception; 3require "/PHPMailer/src/Exception.php"; 4require "/PHPMailer/src/PHPMailer.php"; 5require "/PHPMailer/src/SMTP.php"; 6$body = '—————————————————————————— 7※本メールは配信専用のアドレスからお送りしております。 8—————————————————————————— 9Copyright © 2018 All Rights Reserved.'; 10mb_language("japanese"); 11mb_internal_encoding("UTF-8"); 12$phpmailer = new PHPMailer(true); 13$phpmailer->isSMTP(); 14$phpmailer->Host = ''; 15$phpmailer->SMTPAuth = true; 16$phpmailer->Username = "from_email"; 17$phpmailer->Password = ""; 18$phpmailer->SMTPSecure = 'tls'; 19$phpmailer->Port = 587; 20$phpmailer->setFrom("from_email", mb_encode_mimeheader("from_name", "UTF-8")); 21$phpmailer->addAddress("to_email"); 22$phpmailer->isHTML(false); 23$phpmailer->Encoding = "7bit"; 24$phpmailer->CharSet = 'ISO-2022-JP'; 25$phpmailer->Subject = mb_encode_mimeheader("sub", "UTF-8"); 26$phpmailer->Body = mb_convert_encoding($body, "JIS", "UTF-8"); 27$phpmailer->send();
結果は下記のメールが送信されました。
?????????????????????????? ※本メールは配信専用のアドレスからお送りしております。 ?????????????????????????? Copyright �$(D"m 2018 All Rights Reserved.
こちらを解決する方法はありますでしょうか?
お手数をかけますがよろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/12/28 00:08
2018/12/28 00:29
2019/01/02 08:12
2019/01/03 12:06
2019/01/03 12:19