Codeigniter 获取变量时无法发送电子邮件
我迷路了 当我硬编码变量时,我成功地发送了电子邮件,但一旦我尝试使用数据库和视图构建电子邮件,我会收到以下错误消息:Codeigniter 获取变量时无法发送电子邮件,codeigniter,email,Codeigniter,Email,我迷路了 当我硬编码变量时,我成功地发送了电子邮件,但一旦我尝试使用数据库和视图构建电子邮件,我会收到以下错误消息: 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 这两个功能都在同
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
这两个功能都在同一个控制器中。此功能工作正常:
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
我通过在屏幕上显示每个相关部分进行调试,没有错误
我可以根据需要提供额外的代码
我将非常感谢任何关于如何更好地修复或调试此问题的建议、指导或建议
提前谢谢 我唯一能提出的建议是逐个检查电子邮件代码和硬代码测试变量的每一部分,直到它起作用,并找出是哪一部分导致了问题。jeemus说。此外,我会努力编码的电子邮件从和到第一。然后,如果这不起作用,您可以尝试获取消息体的代码并将其放入视图中,这样可能会更快地进行调试。
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