【发布时间】:2017-03-26 15:02:59
【问题描述】:
我喜欢在本地主机上通过代码设置自动发送电子邮件。 我有 PHP 代码。
但不确定,我需要在本地主机上安装或设置什么,以便我的网站可以自动发送电子邮件。
我的代码如下。
public function sendEmail_post()
{
$jdata = json_decode(file_get_contents('php://input'), true);
$id = $jdata['id'];
$query = $this->Register_model->sendEmail($id);
$email = $query[0]->email;
$token = $query[0]->token;
$user_type = $this->Register_model->roleNames($id);
if ($user_type != "Consumer") {
$user_type = "admin";
} else {
$user_type = "user";
}
$this->email->from('no-reply@xxxxxxx.com', 'XXXXxxxx');
$this->email->to($email);
$this->email->subject('Account Activation');
$this->email->message('
Thanks for signing up!
Your account has been created, you can login with the following credentials after you have activated your account by pressing the url below.
Please click this link to activate your account:
<a href="' . $this->config->item('emailRedirect') . $user_type . '/#/login?auth=' . sha1($email) . '&token=' . sha1($token) . '">Click here<a>'
);
$this->email->set_newline("\r\n");
//$this->db->query('update user set token ="active",status="active" from user where email=$email');
if ($this->email->send()) {
$this->db->query("update user set emailverify='No' where email='$email'");
//$this->Crud_model->verifyEmailID($e_mail);
$this->response(array('result' => 'mail send successfully', 'success' => true), 200);
} else {
$this->response(array('result' => 'Failed to send Email', 'success' => false), 404);
}
}
【问题讨论】:
-
您确定自己是 JavaScript 开发人员吗?这感觉就像 PHP :-?
-
:) 抱歉,我不是网络开发人员。我已经更新了。谢谢
-
如果您想发送电子邮件,您需要一个电子邮件服务器。但是安装自己的服务器很疯狂。我建议您只使用您获得的服务器与您的
xxxxxxx.com托管服务。 -
自动是什么意思?能详细点吗?
标签: javascript php email