2015-06-25 67 views
1

我已经配置以下设置邮件发送但未被接收,笨

$config = Array(

     'protocol' => 'smtp', 
     'smtp_host' => 'ssl://smtp.gmail.com', 
     'smtp_port' => 465, 
     'smtp_user' => '[email protected]', // change it to yours 
     'smtp_pass' => 'xyz', // change it to yours 
     'smtp_timeout'=>20, 
     'mailtype' => 'text', 
     'charset' => 'iso-8859-1', 
     'wordwrap' => TRUE 
     ); 

$this->load->library('email',$config); 
//$this->email->set_newline("\r\n"); 
$this->email->from('[email protected]', 'Garima'); 
$this->email->to('[email protected]'); 

// mail message here 

我得到以下信息:

Your message has been successfully sent using the following protocol: mail

From: "Garima" [email protected]

Return-Path: [email protected]

Reply-To: "[email protected]"

X-Sender: [email protected]

X-Mailer: CodeIgniter

X-Priority: 3 (Normal)

Message-ID: <@gmail.com>

Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit

首先,如果我有定义的协议如SMTP,为什么它将协议显示为邮件。

其次,显示的信息中没有“to”字段。为什么这样?我必须做什么改变?

+0

您使用哪种类型的本地主机进行测试? xammp wamp等 – user4419336

+0

我正在使用xampp – GMehta

+0

另一件事是做一些时间codeigniter不会发送,除非发送电子邮件设置配置在xampp设置https://www.youtube.com/watch?v=TO7MfDcM-Ho – user4419336

回答

0

你忘了在你的代码初始化电子邮件配置设置

$this->email->initialize($config); 

所以,你的代码将

$this->load->library('email'); 
     $config = Array(
       'protocol' => 'smtp', 
       'smtp_host' => 'ssl://smtp.gmail.com', 
       'smtp_port' => 465, 
       'smtp_user' => '[email protected]', // change it to yours 
       'smtp_pass' => 'xyz', // change it to yours 
       'smtp_timeout'=>20, 
       'mailtype' => 'text', 
       'charset' => 'iso-8859-1', 
       'wordwrap' => TRUE 
       ); 

     $this->email->initialize($config);// add this line 

     //$this->email->set_newline("\r\n"); 
     $this->email->from('[email protected]', 'Garima'); 
     $this->email->to('[email protected]'); 
     $this->email->subject('Email Test'); 
     $this->email->message('Testing the email class.'); 
     $this->email->send(); 
     echo $this->email->print_debugger(); 
+0

Thankyou。这使我摆脱了上述问题,但现在它显示了很多错误“fsockopen():无法连接”无法发送数据。 @Saty – GMehta

+0

听起来不错,你摆脱了你的问题!!现在什么样的错误你有请粘贴错误 – Saty

+0

的fsockopen():SSL操作失败,代码1. OpenSSL的错误信息:错误:140770FC:SSL例程:SSL23_GET_SERVER_HELLO:未知协议 的fsockopen():失败,使加密 的fsockopen( ):无法连接到ssl://smtp.gmail.com:587(未知错误) fwrite()期望参数1是资源,布尔给定 这样的错误@Saty – GMehta

0

不要忘了装载库第一

$this->load->library('email'); 

然后配置这些设置Can Refer here too

$config = Array(
    'protocol' => 'smtp', 
    'smtp_host' => 'ssl://smtp.googlemail.com', 
    'smtp_port' => 465, 
    'smtp_user' => 'xxx',//your E-mail 
    'smtp_pass' => 'xxx',//Your password 
    'mailtype' => 'html', 
    'charset' => 'iso-8859-1' 
); 

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

// Set to, from, message, etc. 
$this->email->from('[email protected]', 'Your Name'); 
$this->email->to('[email protected]'); 
$this->email->cc('[email protected]'); 
$this->email->bcc('[email protected]'); 

$this->email->subject('Email Test'); 
$this->email->message('Testing the email class.'); 

$result = $this->email->send(); 

使用本地主机

  1. 发送邮件如果您正在使用XAMPP做到这一点。如果您正在使用WAMPStack Answer for Send mail with WAMP

要读取发送邮件设置Stack Answer for Send mail with XAMPP

  • 更多关于CI的信息E-mail CI E-Mail Library

  • 相关问题