php - 无法在 PHPMailer 中使用(图像)发送电子邮件
问题描述
我想用 PHP 电子邮件发送附件,但它不起作用。你能帮我吗?
require 'class/class.phpmailer.php';
$mail = new PHPMailer;
$mail->IsSMTP();
$mail->SetLanguage("tr", "class/phpmailer.lang-tr.php");
$mail->CharSet ="utf-8";
$mail->Encoding="base64";
$mail->Host = '*****************';
$mail->Port = '587';
$mail->SMTPAuth = true;
$mail->Username = '*********************';
$mail->Password = '*'; *******************
$mail->SMTPSecure = 'tls';
$mail->From = $_POST["email"];
$mail->FromName = $_POST["name"];
$mail->AddAddress('**********************', '***************************');
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->AddAttachment($path);
$mail->Subject = '*************************';
$mail->Body = $message;
if($mail->Send())
{
$message = '<div class="alert alert-success">Destek Talebiniz Tarafımıza Ulaşmıştır</div>';
unlink($path);
}
else
{
$message = '<div class="alert alert-danger">There is an Error</div>';
}
}
解决方案
推荐阅读
- android - 如果数据库中没有任何内容,如何显示“无数据”吐司
- javascript - 查看 p5.js 钢琴乐器的代码
- sql - 是否可以在 SQL 中按语句分区进行多次计算?
- angular - Angular/Ngx 翻译:动态显示从服务器获取的 currentLang
- r - dplyr group_by 并用组的函数替换所有列
- fortran - 每次使用包含模块时都会评估 Fortran 命名常量吗?
- html - 沿 SVG 路径为项目设置动画
- flutter - Flutter 监听 Stateless Widget 上的生命周期事件?
- json - 如何在 Jackson (2.12.0) 和 Quarkus (1.11.1) 中使用 Kotlin (1.4.21) 数据类的默认值
- mysql - 我正在尝试将 MS SQL Server 存储过程转换为 MySQL