所以我正在调试别人写的一些代码,它利用了cakephp蛋糕邮件的东西。我之前从未使用它,也从未在之前编写过电子邮件功能。
当函数执行时,它输出cake标准:"错误:发生内部错误" 以及这一行:
SMTP错误:535 5.7.8 http://support.google.com/mail/bin/answer.py?answer=14257 h66sm5396348yhb.7 - gsmtp
代码在这里:
public function newAppEmail($email_addr, $password) {
$Email = new CakeEmail();
$Email->config('default');
$Email->sender(array('polarontest@gmail.com' => 'Polaron'));
$Email->from(array('polarontest@gmail.com' => 'Polaron'));
$Email->to($email_addr);
$Email->subject('Eligibility Check');
$Email->template('newapp');
$Email->emailFormat('text');
$Email->viewVars(array('name' => $this->request->data['Applicant']['first_name'], 'email' => $this->request->data['Applicant']['email'], 'password' => $password));
$Email->attachments(array(
'Polaron - PL Passport - Info Pack - 2013.pdf' => array(
'file' => APP . 'documents/Email_attachments/Polaron - PL Passport - Info Pack - 2013.pdf',
'mimetype' => 'pdf'),
));
$Email->send();
}
这是配置文件:
<?php
class EmailConfig {
public $default = array(
'transport' => 'Smtp',
'from' => array('email@email.com' => 'company name'),
'sender' => array('email@email.com' => 'company name'),
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => 'email@email.com',
'password' => 'password');
public $fast = array(
'transport' => 'Smtp',
'from' => array('email@email.com' => 'Test Mail name sender'),
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => 'email@email.com',
'password' => 'password');
}
任何人都可以了解可能出现的问题以及我应该在哪些方面解决问题?
答案 0 :(得分:0)
嗯,SMTP错误535意味着身份验证失败,很容易找到。
因此抛出异常。所以获得正确的凭据并再试一次,这不是php代码的问题,而是你的凭据。
答案 1 :(得分:0)
如果您的登录名/密码正确,请测试配置:
public $smtp = array(
'transport' => 'Smtp',
'from' => array('email@gmail.com' => 'Name'),
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'timeout' => 30,
'username' => 'email@gmail.com',
'password' => '**********',
'client' => null,
'log' => false,
'charset' => 'utf-8',
'headerCharset' => 'utf-8',
);