2015-10-16 94 views
0

當Description與附件一起增加超過3000個字符時,我無法發送電子郵件。這裏是示例代碼。在Codeigniter中使用SMTP發送詳細說明以及附件

   $mail->IsSMTP();      //send via SMTP 
       $mail->Host  = SMTP_HOST;   //SMTP servers 
       $mail->SMTPDebug = 1; 

       $mail->SMTPAuth = true; 
       $mail->SMTPSecure = "tls"; 
       $mail->Host  = SMTP_HOST;   //SMTP servers 
       $mail->Port  = 25; 
       $mail->Username = USER_NAME; 
       $mail->Password = USER_PWD; 

       $mail->From  = $from_email; 
       $mail->FromName = $from_name; 

       $mail->ContentType = "text/html"; 

       $mail->WordWrap = 180;     // set word wrap 
       $mail->CharSet = 'UTF-8'; 
       $mail->IsHTML(true); 

       $mail->AddAddress($to_add, $to_name); 
       $mail->Subject = "Tutorial get Answered"; 

       $HTML = "<p>Your tutorial is ready now,</p>"; 
       $HTML .= "<p>Question ID: " . $q_id. "</p>"; 
       $HTML .= "<p>Question : " . $row['description'] . "</p>"; 
       $HTML .= "<p>Posted on: " . $row['created_on'] . "</p>"; 
       $HTML .= "<p><a href=base_url().'/" . $row['id'] . "/" . my_text($row['description']) . "'>SHOW TUTORIAL</a></p>"; 
       $HTML .= "<p><br><br>Thank you.</p>"; 

       $mail->Body=$HTML; 

       $mail->Send(); 
       $msg="Mail send into your email"; 

它工作正常對於小的描述,但如果描述增加它顯示郵件發送但它不顯示在收件箱中。

+2

附上代碼示例和詳細的錯誤描述。 –

回答

0

檢查CI Email Library Guide並請使用以下格式:

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

$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.'); 
$this->email->set_mailtype('html'); 

$this->email->send(); 

這大概結構將解決你的問題,因爲我用這個一個沒有任何問題。

0
$email = $this->input->post('email');  

$config = Array(
'protocol' => 'smtp', 
'smtp_host' => 'ssl://smtp.googlemail.com', 
'smtp_port' => 465, 
'smtp_user' => '**********@gmail.com', 
'smtp_pass' => '********', 
'mailtype' => 'html', 
'charset' => 'utf-8', 
'wordwrap' => TRUE 
);    
     //send email with #temp_pass as a link 
     $this->load->library('email', $config); 
     $this->email->set_newline("\r\n"); 
     $this->email->from('*********@gmail.com', "Name"); 
     $this->email->to($email); 
     $this->email->subject("Reset your Password"); 

     $message = "<p>****************</p>"; 
     $message. = "<p>****************</p>"; 
     $this->email->message($message); 
     $this->email->send(); 
相關問題