2013-11-25 1 views
0

Я совершенно новый для codeigniter .. Я хочу отправить электронное письмо с моего сервера, используя электронную библиотеку CI. Я сделал код, и он отлично работал на локальном хосте, но не работал на моем сервере.codeigniter отправить e-mail сбой с реального сервера

Это моя функция в контроллере:

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") 

У вас есть файл 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(); 
     } 
Смежные вопросы