我正嘗試在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帳戶:)。 –