有人可以帮助我"迁移"这个表格到G SMTP而不是PHP?你可以看到我在下面尝试过但我没有让它工作。我尝试使用谷歌搜索和搜索整个图书馆,但没有成功。有谁知道它有什么问题吗?提前谢谢!
我当前的脚本如下所示:
if (count($email_body) > 0)
{
$new_password = substr(md5(microtime()),rand(0,26),7);
$this->email->from('email@email.com', 'Email - New Password');
$this->email->to($choosenuser[0]->email);
$parentss = array("[[firstname]]", "[[lastname]]", "[[new_pass]]", "[[base_url]]");
$words = array($choosenuser[0]->firstname, $choosenuser[0]->lastname, $new_password, base_url());
$subject = str_replace($parentss, $words, $email_body[0]->subject);
$this->email->subject($subject);
$parentss = array("[[firstname]]", "[[lastname]]", "[[new_pass]]", "[[base_url]]");
$words = array($choosenuser[0]->firstname, $choosenuser[0]->lastname, $new_password, base_url());
$text_obavestenja = str_replace($parentss, $words, $email_body[0]->tekst);
if ($this->input->post('type') == 'trainer')
{
$this->baza_model->izmeni_slog_array('lag_users', Array('id' => $choosenuser[0]->id), Array('password' => md5($new_password)));
}else{
$this->baza_model->izmeni_slog_array('lag_challenge_users', Array('id' => $choosenuser[0]->id), Array('password' => md5($new_password)));
}
$this->email->message($text_obavestenja);
$this->email->set_mailtype("html");
$this->email->send();
//echo $this->email->print_debugger();
}else{
redirect('front/message/e-mail-message-missing', 'refresh');
}
redirect('front/message/passwordset/', 'refresh');
我尝试了什么:
if (count($email_body) > 0)
{
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'auth' => true,
'smtp_user' => $this->config->item("user", "EMAIL"),
'smtp_pass' => $this->config->item("pass", "Password"),
'mailtype' => 'html',
'charset' => 'utf-8'
);
$this->email->initialize($config);
$new_password = substr(md5(microtime()),rand(0,26),7);
$this->email->from('<' . $this->config->item("email", "email_from") . '>', $this->config->item("name", "email_from"));
$this->email->to($this->config->item($choosenuser[0]->email));
$parentss = array("[[firstname]]", "[[lastname]]", "[[new_pass]]", "[[base_url]]");
$words = array($choosenuser[0]->firstname, $choosenuser[0]->lastname, $new_password, base_url());
$subject = str_replace($parentss, $words, $email_body[0]->subject);
$this->email->subject($subject);
$parentss = array("[[firstname]]", "[[lastname]]", "[[new_pass]]", "[[base_url]]");
$words = array($choosenuser[0]->firstname, $choosenuser[0]->lastname, $new_password, base_url());
$text_obavestenja = str_replace($parentss, $words, $email_body[0]->tekst);
if ($this->input->post('type') == 'trainer')
{
$this->baza_model->izmeni_slog_array('lag_users', Array('id' => $choosenuser[0]->id), Array('password' => md5($new_password)));
}else{
$this->baza_model->izmeni_slog_array('lag_challenge_users', Array('id' => $choosenuser[0]->id), Array('password' => md5($new_password)));
}
$this->email->message($text_obavestenja);
$this->email->set_mailtype("html");
$this->email->send();
//echo $this->email->print_debugger();
}else{
redirect('front/message/e-mail-message-missing', 'refresh');
}
redirect('front/message/passwordset/', 'refresh');
当我把调试器放在什么都不显示时。日志是空的。
答案 0 :(得分:0)
即使您的所有Google SMTP连接设置都正确无误,您仍需要告知Google信任您的应用:
https://support.google.com/accounts/answer/6010255?hl=en
https://myaccount.google.com/lesssecureapps?pli=1
在我的CodeIgniter应用中,唯一的区别是您使用的是ssl://smtp.googlemail.com,而我使用的是ssl://smtp.gmail.com。这就是为什么我认为您的问题是需要告诉Google信任该应用。