我使用系统来管理约会:http://easyappointments.org/ 系统运行顺畅,但我在使用此软件+ phpmailer发送邮件时遇到问题 - 该项目集成在此项目中。
问题是: 当我只是安装它并完成软件所做的一切时,它运行顺利但不发送电子邮件。但是没有产生错误。
这是示例和原始代码:
// :: INSTANTIATE EMAIL OBJECT AND SEND EMAIL
$mail = new PHPMailer();
$mail->From = $company_settings['company_email'];
$mail->FromName = $company_settings['company_name'];
$mail->AddAddress($receiver_address); // "Name" argument crushes the phpmailer class.
$mail->IsHTML(true);
$mail->CharSet = 'UTF-8';
$mail->Subject = $title;
$mail->Body = $email_html;
if (!$mail->Send()) {
throw new Exception('Email could not been sent. Mailer Error (Line '
. __LINE__ . '): ' . $mail->ErrorInfo);
}
return TRUE;
所以我尝试编辑notifications.php以匹配提供的服务器smtp:
// :: INSTANTIATE EMAIL OBJECT AND SEND EMAIL
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Port = 587; //Indica a porta de conexão para a saída de e-mails
$mail->Host = 'smtp.site123.com.br'; //smtp.dominio.com.br
$mail->SMTPAuth = true; //define se haverá ou não autenticação no SMTP
$mail->Username = 'contato@site123.com.br'; //Informe o e-mai o completo
$mail->Password = 'goodpassword'; //Senha da caixa postal
$mail->From = $company_settings['company_email'];
$mail->FromName = $company_settings['company_name'];
$mail->AddAddress($receiver_address); // "Name" argument crushes the phpmailer class.
$mail->IsHTML(true);
$mail->CharSet = 'UTF-8';
$mail->Subject = $title;
$mail->Body = $email_html;
if (!$mail->Send()) {
throw new Exception('Email could not been sent 1. Mailer Error (Line '
. __LINE__ . '): ' . $mail->ErrorInfo);
}
return TRUE;
当我这样做时,easy的日志告诉我:
ERROR - 2016-11-07 12:32:22 --> Severity: Warning --> stream_socket_enable_crypto(): Peer certificate CN=`*.locaweb.com.br' did not match expected CN=`smtp.site123.com.br' /home/storage/9/7c/40/site123/public_html/site/agenda/application/third_party/phpmailer/phpmailer/class.smtp.php 344
ERROR - 2016-11-07 12:32:22 --> Email could not been sent. Mailer Error (Line 134): SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
ERROR - 2016-11-07 12:32:22 --> #0 /home/storage/9/7c/40/site123/public_html/site/agenda/application/controllers/appointments.php(445): Notifications->send_appointment_details(Array, Array, Array, Array, Array, 'O seu hor&aacut...', 'Obriagado por a...', 'http://site123...', 'felipe@tecnicos...')
#1 [internal function]: Appointments->ajax_register_appointment()
#2 /home/storage/9/7c/40/site123/public_html/site/agenda/system/core/CodeIgniter.php(360): call_user_func_array(Array, Array)
#3 /home/storage/9/7c/40/site123/public_html/site/agenda/index.php(229): require_once('/home/storage/9...')
#4 {main}
确定!我阅读并前往https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting看看是否有帮助。有一段代码说:
正确的解决方法是用一个好的证书替换无效,配置错误或自签名的证书。如果不这样做,您可以通过PHPMailer 5.2.10中引入的SMTPOptions属性允许不安全的连接(可以通过在早期版本中继承SMTP类来实现这一点),但不建议这样做:
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
确定!我这样做。所以系统错误日志告诉我:
ERROR - 2016-11-07 19:04:41 --> Email could not been sent. Mailer Error (Line 141): SMTP Error: The following recipients failed: felipe@tecnicosvirtuais.com.br: <felipe@tecnicosvirtuais.com.br>: Recipient address rejected: Access Denied
ERROR - 2016-11-07 19:04:41 --> #0 /home/storage/9/7c/40/site123/public_html/site/agenda/application/controllers/appointments.php(445): Notifications->send_appointment_details(Array, Array, Array, Array, Array, 'O seu hor&aacut...', 'Obriagado por a...', 'http://site123...', 'felipe@tecnicos...')
#1 [internal function]: Appointments->ajax_register_appointment()
#2 /home/storage/9/7c/40/site123/public_html/site/agenda/system/core/CodeIgniter.php(360): call_user_func_array(Array, Array)
#3 /home/storage/9/7c/40/site123/public_html/site/agenda/index.php(229): require_once('/home/storage/9...')
#4 {main}
而我就像......现在? 谷歌搜索大约10个小时,并尝试任何可以核心化的东西...没有...尝试更改电子邮件类等等......没有...在上述3个案例中系统运行正常但不发送邮件!
答案 0 :(得分:0)
我认为我的想法可以为您提供帮助。
您打开文件wp-content/plugins/easyappointments/vendor/phpmailer/phpmailer/class.phpmailer.php
您必须搜索并设置以下内容:
public $Mailer = 'smtp';
public $Host = 'smtp.gmail.com';
public $SMTPSecure = 'tls';
public $Port = 587;
public $SMTPAuth = true;
public $Username = 'username@gmail.com';
public $Password = 'mypassword';
测试预订,您将看到电子邮件已发送。 希望这种方式能对您有所帮助。