2011-07-28 5 views
1

에 오류가이 이메일 sendind 코드이메일은 CodeIgniter의

function send_letter() 

    { 

     $description = $this->input->post('description',true); 

     $this->load->model('newsletter_model'); 

     $this->data['mail_list'] = $this->newsletter_model->getmaillist(); 

     $this->email->from('[email protected]', 'Imageinit'); 

     $this->email->subject('Email Test'); 

     $this->email->message($description); 

     foreach($this->data['mail_list'] as $val) 

     { 

      $this->email->set_newline("\r\n"); 

      $this->email->to($val['emailid']); 

      $this->email->send(); 

     } 


     $this->index(); 

    } 

이메일은 "nosubject"또한

오류가

을 보여줍니다 같은 모든 emailids..But 대상에 성공적으로 전송 보여줍니다

보안 : 알림

메시지 : 정의되지 않음 색인 : 제목

파일 이름 : 라이브러리/email.php로

줄 번호 : email.php로 라인 941에서 941

내용이 분명히

if ($this->protocol == 'mail') 

     { 

      $this->_subject = $this->_headers['Subject']; 

      unset($this->_headers['Subject']); 
     } 

답변

1

코드 인 unset s를 Subject 헤더 send에서 호출되는 _build_message에서 호출되는 _write_headers 메서드에 있습니다. 따라서 sendmail으로 백엔드로 호출 할 때마다 피사체는 지워집니다 (하지만 첫 번째 메일은 괜찮습니다. 피사체는 $this->_subject에 저장되기 때문에 후속 호출에서도 빈 문자열로 덮어 쓰게됩니다).

이것은 email.php로의 버그처럼 보이지만 해결 방법으로 당신은 단지 루프의 모든 반복에 피사체가 (그래서 그냥 어쩌면 to 울어 후 foreach -loop의 내부 $this->email->subject('Email Test'); 이동) 설정할 수 있습니다 .

+0

이> 이메일 -> 주제 ('이메일 테스트') $ this-를 넣어 ya..i; loop.Now 괜찮아요 .. 내부 .. – Ashitha

0

사용이 코드

기능 send_letter()

{ 

    $description = $this->input->post('description',true); 

    $this->load->model('newsletter_model'); 

    $this->data['mail_list'] = $this->newsletter_model->getmaillist(); 



    foreach($this->data['mail_list'] as $val) 

    { 

     $this->email->from('[email protected]', 'Imageinit'); 

     $this->email->subject('Email Test'); 

     $this->email->message($description); 


     $this->email->set_newline("\r\n"); 

     $this->email->to($val['emailid']); 

     $this->email->send(); 

    } 


    $this->index(); 

}