2013-11-25 2 views
0

저는 codeigniter가 새로 생겼습니다. CI의 전자 메일 라이브러리를 사용하여 내 서버에서 전자 메일을 보내려고합니다. 코드를 작성했지만 로컬 호스트에서 완벽하게 작동하지만 내 서버에서는 작동하지 않습니다.codeigniter는 실제 서버에서 전자 메일을 보내지 못합니다.

이 컨트롤러 내 기능입니다 :

public function send_task(){ 
    $config = Array(
     'protocol' => "smtp", //when you use gmail 
     'smtp_host' => "smtp.googlemail.com", 
     'smtp_port' => 465, 
     'smtp_user' => "[email protected]", 
     'smtp_pass' => "******", 
    ); 

    $config['crlf'] = '\r\n'; 
    $config['newline'] = '\r\n'; 
     $this->load->library('email', $config); 

     $this->email->from('[email protected]', 'Media Club - Sales'); 
     $this->email->to('[email protected]'); 
     $this->email->subject('Sales System New Task'); 
     $this->email->message('Hi There'); 

     if($this->email->send()) { 
      echo 'Email sent.'; 
     }else { 
      show_error($this->email->print_debugger()); 
     }  
    } 

과 오류는 다음과 같습니다 enter image description here

나는이 구성에서 뭐가 잘못 됐는지 모르겠어요. 그래서 나는 정말로 도움이 필요하다. :) 사전에 감사합니다 :)이와

답변

1

시도, 당신은

$config = Array(  
      'protocol' => 'smtp', 
      'smtp_host' => 'ssl://smtp.googlemail.com', 
      'smtp_port' => 465, 
      'smtp_user' => '<your username>@gmail.com', 
      'smtp_pass' => '<your password>', 
      'smtp_timeout' => '4', 
      'mailtype' => 'text', 
      'charset' => 'iso-8859-1' 
     ); 

     $this->load->library('email', $config); 
     $this->email->set_newline("\r\n") 

당신은 당신의 config 폴더에 email.php로 파일이 도움이 될 수 있습니다. 어쩌면 거기에 구성에 문제가있을 수 있습니다. 그 하나도 확인하십시오.

+0

작동하지 않습니다. 제 문제는 서버와 관련이 있다고 생각합니다. 서버의 SMTP 설정에 대한 구성을해야합니까? – Fareed

+0

smtp_port를 25로 변경하고 다시 확인해보십시오. 도움이 될 것 같습니다. –

+0

알았어. 내가 뭘 잘못했는지 알았어. 내 Gmail이 diffirent 한 서버에 로그인하는 것을 허용해야만 해. – Fareed

1
function send_email(){ 
     $this->emailformat(); 
}  

function emailformat(){ 
       $config['protocol'] = 'smtp'; // mail, sendmail, or smtp The mail sending protocol. 
       $config['smtp_host'] = '10.10.20.20'; // SMTP Server Address. 
       $config['smtp_user'] = '[email protected]'; // SMTP Username. 
       $config['smtp_pass'] = '12345'; // SMTP Password. 
       $config['smtp_port'] = '25'; // SMTP Port. 
       $config['smtp_timeout'] = '5'; // SMTP Timeout (in seconds). 
       $config['wordwrap'] = TRUE; // TRUE or FALSE (boolean) Enable word-wrap. 
       $config['wrapchars'] = 76; // Character count to wrap at. 
       $config['mailtype'] = 'html'; // text or html Type of mail. If you send HTML email you must send it as a complete web page. Make sure you don't have any relative links or relative image paths otherwise they will not work. 
       $config['charset'] = 'utf-8'; // Character set (utf-8, iso-8859-1, etc.). 
       $config['validate'] = FALSE; // TRUE or FALSE (boolean) Whether to validate the email address. 
       $config['priority'] = 3; // 1, 2, 3, 4, 5 Email Priority. 1 = highest. 5 = lowest. 3 = normal. 
       $config['crlf'] = "\r\n"; // "\r\n" or "\n" or "\r" Newline character. (Use "\r\n" to comply with RFC 822). 
       $config['newline'] = "\r\n"; // "\r\n" or "\n" or "\r" Newline character. (Use "\r\n" to comply with RFC 822). 
       $config['bcc_batch_mode'] = FALSE; // TRUE or FALSE (boolean) Enable BCC Batch Mode. 
       $config['bcc_batch_size'] = 200; // Number of emails in each BCC batch. 

        $this->load->library('email'); 
        $this->email->initialize($config); 
        $this->email->from('[email protected]', 'Robot'); 
        $this->email->to('[email protected]'); 
        $this->email->subject('subject'); 
        $this->email->message('<html><body>This Message is to notify you that '.$c_id.' contract will expire in' !</body></html>'); 
        $this->email->send(); 
     } 
관련 문제