2013-09-03 8 views
16
public function sendemail(){ 
    $config = Array( 
    'protocol' => 'smtp', 
    'smtp_host' => 'ssl://smtp.googlemail.com', 
    'smtp_port' => 465, 
    'smtp_user' => '[email protected]', 
    'smtp_pass' => 'password',); 

    $this->load->library('email', $config); 
    $this->email->set_newline("\r\n"); 
    $this->email->from('[email protected]', 'Name'); 
    $this->email->to('[email protected]'); 
    $this->email->subject(' My mail through codeigniter from localhost '); 
    $this->email->message('Hello World…'); 
    if (!$this->email->send()) { 
    show_error($this->email->print_debugger()); } 
    else { 
    echo 'Your e-mail has been sent!'; 
    } 
} 

के माध्यम से CodeIgniter लाइब्रेरी का उपयोग करके ईमेल भेजें जब मैं CodeIgniter का उपयोग ईमेल भेजने के लिए मैं कोई त्रुटि मिलती है:स्थानीय होस्ट

Message: mail() [function.mail]: Failed to connect to mailserver at 
"localhost" port 25, verify your "SMTP" and "smtp_port" setting in 
php.ini or use ini_set(). 

और

Unable to send email using PHP mail(). Your server might not be 
configured to send mail using this method. 

क्या मैं गलत कर रहा हूँ?

उत्तर

29

कृपया मेरा काम कोड देखें।

function sendMail() 
{ 
    $config = Array(
    'protocol' => 'smtp', 
    'smtp_host' => 'ssl://smtp.googlemail.com', 
    'smtp_port' => 465, 
    'smtp_user' => '[email protected]', // change it to yours 
    'smtp_pass' => 'xxx', // change it to yours 
    'mailtype' => 'html', 
    'charset' => 'iso-8859-1', 
    'wordwrap' => TRUE 
); 

     $message = ''; 
     $this->load->library('email', $config); 
     $this->email->set_newline("\r\n"); 
     $this->email->from('[email protected]'); // change it to yours 
     $this->email->to('[email protected]');// change it to yours 
     $this->email->subject('Resume from JobsBuddy for your Job posting'); 
     $this->email->message($message); 
     if($this->email->send()) 
    { 
     echo 'Email sent.'; 
    } 
    else 
    { 
    show_error($this->email->print_debugger()); 
    } 

} 
+0

क्या स्थानीयहोस्ट में कोई कॉन्फ़िगरेशन है इसलिए ईमेल भेजा जा सकता है? –

+0

हाँ आपको अपने लोकहोस्ट –

+0

में openssl को सक्षम करना होगा क्यों हर बार जब मैं $-- email-> से ('[email protected] ') बदलता हूं; याहू जैसे अन्य पते पर, मुझे प्राप्त ईमेल हमेशा प्रेषक के बजाय 'मुझे' से भेजा जाता है? –

2

मैं एक ही समस्या थी और मैं postcast server का उपयोग करके हल किया। आप इसे स्थानीय रूप से स्थापित कर सकते हैं और इसका उपयोग कर सकते हैं।

संबंधित मुद्दे