【发布时间】:2019-10-01 18:55:52
【问题描述】:
如何解决这个错误?我做了所有可能的事情来解决这个问题,但它无法解决。这是我的 .env 文件代码
MAIL_DRIVER=smtp
MAIL_HOST=fluorine.cloudhosting.co.uk
MAIL_PORT=465
MAIL_USERNAME=contacts@cleansafeltd.com
MAIL_PASSWORD=Hggjgjgghv123
MAIL_ENCRYPTION=ssl
这里是mail.php的代码
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'fluorine.cloudhosting.co.uk'),
'port' => env('MAIL_PORT', 465),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'contacts@cleansafeltd.com'),
'name' => env('MAIL_FROM_NAME', 'Contact'),
],
'encryption' => env('MAIL_ENCRYPTION', 'ssl'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
这是邮件控制器
public function sendMail($to_email, $template_id, $users_insertId = 0) {
set_time_limit(0);
$mail = new PHPMailer(true);
$mail->IsSendmail();
$mail->IsSMTP(true);
$mail->Host = "fluorine.cloudhosting.co.uk";
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Username = "website@cleansafeltd.com";
$mail->Password = "Star9000!";
$mail->Port = "465";
$mail->IsHTML(true);
}
我也用 tls 或端口 587 做所有的事情,但没有解决。
【问题讨论】:
-
关注the PHPMailer troubleshooting guide。当您使用 SMTP 时,您无需致电
isSendmail()。其他设置看起来不错,因此您的 ISP 可能会阻止出站 SMTP。设置$mail->SMTPDebug = 3并查看调试输出的内容。该指南将帮助您找出问题所在。