2014-01-19 139 views
0

我做簡單的表格用戶提交電子郵件和城市提交表格和發送電子郵件給我的用戶感謝我的網站上godaddy,當我提交它顯示錯誤。 1-發送電子郵件錯誤 2- $電子郵件輸入沒有得到 建議我共享代碼。Codeigniter - 面對問題發送電子郵件和輸入用戶電子郵件

user.php的控制器

public function sendUserMail($email) { 
    $this->load->library('email'); 
    $email = $this->input->get("email"); 
    $this->email->from('[email protected]', 'Halalat'); 
    $this->email->to('$email'); 
    $this->email->subject('Halalat Newsletter Subscription'); 
    $this->email->message('Testing'); 
    //$this->email->attach('/assests/images/photo1.jpg'); 
    $this->email->send(); 
    echo $this->email->print_debugger(); 
    } 

在CONFIG夾i使email.php

<?php 

$config['protocol'] = 'smtp'; 
$config['smtp_host'] = 'host.abc.com'; 
$config['smtp_port'] = '465'; 
$config['smtp_user'] = '[email protected]'; 
$config['smtp_pass'] = 'abc'; 
$config['charset'] = 'utf-8'; 
$config['mailtype'] = 'html'; 
$config['newline'] = "\r\n"; 

?> 

user_model.php在模型

function create_member() 
{ 
    $new_member_insert_data = array(
    'email' => $this->input->post('email'), 
    'city' => $this->input->post('city'),  
    ); 
    $insert = $this->db->insert('users', $new_member_insert_data); 
    return $insert; 


} //create_member 
+0

請也張貼錯誤信息。 –

回答

0

試試這個吧,

$this->load->library('email'); 
    $config['protocol'] = 'smtp'; 
    $config['smtp_host'] = 'ssl://host.abc.com'; 
    $config['smtp_port'] = '465'; 
    $config['smtp_user'] = '[email protected]'; 
    $config['smtp_pass'] = 'abc'; 
    $config['charset'] = 'utf-8'; 
    $config['mailtype'] = 'html'; 
    $config['wordwrap'] = TRUE; 
    $this->email->initialize($config); 
    $email = $this->input->get("email"); 
    $this->email->from('[email protected]', 'Halalat'); 
    $this->email->to('$email'); 
    $this->email->subject('Halalat Newsletter Subscription'); 
    $this->email->message('Testing'); 
    if(!$this->email->send()){ 
    echo $this->email->print_debugger(); 
    } 
+0

我已經做$ email,但這個變量不起作用,如果你需要我會分享所有的代碼 – FormaL

+0

你確定主機和端口是否正確?錯誤報告說什麼? –

+0

先查看error_log文件,然後分享你的錯誤! –