我在codeigniter中使用smtp,我尝试了这段代码。
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'xxx@gmail.com', // change it to yours
'smtp_pass' => 'xxx', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->email->set_newline('\r\n');
$this->email->from('email@email.com', 'Testing');
$this->email->reply_to('email@email.com', 'Testing');
$this->email->to('email@email.com');
$this->email->cc('email@email.com');
$this->email->subject('Testing');
$this->email->message($message);
$this->email->send();
但我不明白smtp_user和smtp_pass必须给出什么。任何人都可以打电话给我!!
答案 0 :(得分:0)
smtp_user adn smtp_pass是您的gmail帐户的用户名和密码。请阅读此文档https://www.digitalocean.com/community/tutorials/how-to-use-google-s-smtp-server