【发布时间】:2020-01-12 18:29:09
【问题描述】:
大家好,我在使用 gmails SMTP 服务器发送邮件时遇到问题。它最近工作得很好,我的项目离开了两天,当我回来时它停止了。请帮忙。我尝试更改 php.ini 中的 smtp 端口和所有必要的东西,但没有。我正在尝试添加新用户,但使用 google smtp 服务器向新用户发送验证电子邮件。这是我的“加入控制器”代码。
function _email($email, $activation_code)
{
$config = [
'mailtype' => 'html',
'charset' => 'utf-8',
'protocol' => 'smtp',
'smtp_host' => 'smtp.gmail.com',
'smtp_user' => 'someone@gmail.com', // gmail address
'smtp_pass' => 'xxxxxxx', // gmail password
'smtp_crypto' => 'ssl',
'smtp_port' => 465,
'crlf' => "\r\n",
'newline' => "\r\n"
];
$this->load->library('email', $config);
$this->email->from('someone@gmail.com', 'username');
$this->email->to($email);
$this->email->subject('[Confirmation Email]');
$html = '
<div style="margin-bottom: 20px; font-weight: bold;">Hello There,</div>
<div>Thank you for using and for join.</div>
<div style="margin-bottom: 10px;">To activate your account, please click this link and we will redirect you to login page: <a href="'.base_url('activate?code='.$kode_aktifasi.'&email='.$email).'">Confirm my email address</a>.
</div>
<div>If that link cannot working you can access this URL from your browser</div>
<div><a href="'.base_url('activate?code='.$kode_aktifasi.'&email='.$email).'">'.base_url('activate?code='.$kode_aktifasi.'&email='.$email).'</a></div>
<div style="margin-bottom: 20px; margin-top: 10px;">If you have a question reply this email and we will contact you as soon as possible, thank you!</div>
';
$this->email->message($html);
return $this->email->send();
}
}
然后这是我得到的错误: PHP Error
【问题讨论】:
-
load->library是做什么的?请添加功能。来自错误smtp_hostis not being used -
你能发布你得到的错误的确切输出,你在哪一行得到这些?
-
我投票决定将此问题作为离题结束,因为它与代码无关。
it is the avast antivirus which was blocking my port