我正尝试在codeigniter中发送电子邮件,并且这是我正在使用的一段代码。第一个评论的代码打印错误,说我的应用程序没有配置发送电子邮件。在codeigniter中通过Google邮件发送电子邮件
使用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' => '[email protected]',
'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("[email protected],[email protected],[email protected]");
$this->email->subject("Hello world");
$this->email->subject("Hello world from local pc");
$this->email->send();
$data['msg']=$this->email->print_debugger();
您可以为此创建一个新的Gmail帐户:)。 –