我正在尝试在 codeigniter 中发送电子邮件,这是我正在使用的一段代码。第一个注释代码打印错误说我的应用程序没有发送电子邮件的配置。
使用 gmail 的第二个未注释代码工作正常,但需要显示我的电子邮件和密码。所以我有两个问题:如何在不提及密码的情况下做我想做的事。这在软件开发中是否可以接受提及用户密码。谢谢
/*$config = array();
$config['useragent'] = "CodeIgniter";
$config['mailpath'] = "/usr/bin/sendmail"; // or "/usr/sbin/sendmail"
$config['protocol'] = "mail";
$config['smtp_host'] = "localhost";
$config['smtp_port'] = "25";
$config['mailtype'] = 'text';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['wordwrap'] = TRUE;
*/
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => '465',
'smtp_user' => 'myemail@gmail.com',
'smtp_pass' => 'mypass',
'mailtype' => 'text',
'starttls' => true,
'newline' => "\r\n"
);
$this->load->library('email',$config);
$email=$this->input->post("email");
$username=$this->input->post("username");
$this->email->to("receiver1@gmail.com,receiver2@gmail.com,receiver3@yahoo.fr");
$this->email->subject("Hello world");
$this->email->subject("Hello world from local pc");
$this->email->send();
$data['msg']=$this->email->print_debugger();