我迷路了。
当我对变量进行硬编码时,我成功发送了电子邮件,但是一旦我尝试使用数据库和视图构建电子邮件,我收到此错误消息:
A PHP Error was encountered
Severity: Warning
Message: mail(): Could not execute mail delivery program '/usr/sbin/sendmail -t -i'
Filename: libraries/Email.php
Line Number: 1553
有问题的两个函数都在SAME控制器中。这个功能很好用:
public function test_send(){
$this->load->library('email');
$config['mailtype'] = 'html';
$this->email->initialize($config);
$msgThx = "<!doctype html><html><head><meta charset='utf-8'><title>Just a Test</title></head><body><p><strong>Testing Email Function</strong></p></body></html>";
$this->email->from('jgravois@edrtrust.com', 'Jonathan Gravois');
$this->email->to('jgravois@edrtrust.com');
$this->email->subject('Just a Test');
$this->email->message($msgThx);
if($this->email->send()){
echo 'Your email was sent successfully.';
} else {
show_error($this->email->print_debugger());
} // end if
} // end test_send function
现在要创建用于确认学生人员申请的电子邮件,我使用此功能,但由于上述错误而失败:
public function send_ca_job_email($id){
$app = $this->mcms->getTeamAppForEmail($id);
$data['app'] = $app;
$data['appDate'] = $app[0]['appDate'];
$prp = $app[0]['propNumber'];
$data['propNumber'] = $prp;
$rsProperty = $this->mcms->getPropInfo( $prp );
$data['rsProperty'] = $rsProperty;
$data['recLink'] = $rsProperty[0]['propertyProductionURL'].'index.php/prop/recommend/'.$id;
switch($data['rsProperty'][0]['propertyCaRa']){
case 'RA':
$data['aTitle'] = 'RA';
$data['aInitials'] = 'Resident Assistant';
break;
case 'VV':
$data['aTitle'] = 'CA';
$data['aInitials'] = 'Community Assistant';
break;
case 'SM':
$data['aTitle'] = 'RA';
$data['aInitials'] = 'Resident Advisor';
break;
default:
$data['aTitle'] = 'CA';
$data['aInitials'] = 'Community Assistant';
break;
} // end switch
// print_r($data); die();
$subject = "Your Application Has Been Received at {$data['rsProperty'][0]['propertyName']}!";
$msgThx = $this->load->view('email/resend_team_application_email', $data, TRUE );
// echo $msgThx; die();
// send email
$this->load->library('email');
$config['mailtype'] = 'html';
$this->email->initialize($config);
$this->email->from($rsProperty[0]['propertyEmail'], $rsProperty[0]['propertyName']);
$this->email->to($app[0]['email']);
$this->email->subject($subject);
$this->email->message($msgThx);
if($this->email->send()){
echo 'Your email was sent successfully.';
} else {
show_error($this->email->print_debugger());
} // end if
// redirect('conn/caReport', 'redirect');
} // end get_ca_job_email function
我通过在屏幕上显示每个相关部分进行调试,并且没有错误。
我可以根据需要提供其他代码。
我非常感谢有关如何更好地修复或调试此问题的任何建议,指导或建议。
提前致谢!