我可以通过原生 PHP 函数发送电子邮件,但是当我尝试使用 CI 电子邮件类时,邮件不会发送。我在 Amazon EC2 服务器上使用 Ubuntu。
使用 PHP(工作):
$to = 'test@test.com'; // mail address I am using is real
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
Codeigniter(不工作):
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_port'] = '25';
$config['mailtype'] = 'html';
$this->email->from('your@example.com', 'Your Name');
$this->email->to('imalimalomrk@gmail.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->initialize($config);
var_dump($this->email->send());
最佳答案
如果 var_dump()
被移除并离开 $this->email->send()
只要?
或者,您可以加载和使用 email helper相反,这将允许您以更多(PHP) native 方式发送邮件。
关于php - Codeigniter 3,ubuntu - 使用原生 PHP 邮件功能发送邮件,但不使用 CI 电子邮件类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28679798/