Php 在Codeigniter中使用SMTP发送长描述和附件
我无法发送电子邮件时,随着附件的描述增加了3000多个字符。下面是示例代码Php 在Codeigniter中使用SMTP发送长描述和附件,php,codeigniter,smtp,Php,Codeigniter,Smtp,我无法发送电子邮件时,随着附件的描述增加了3000多个字符。下面是示例代码 $mail->IsSMTP( ); //send via SMTP $mail->Host = SMTP_HOST; //SMTP servers $mail->SMTPDebug = 1; $mai
$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";
$mail->IsSMTP()//通过SMTP发送
$mail->Host=SMTP\u主机//SMTP服务器
$mail->SMTPDebug=1;
$mail->SMTPAuth=true;
$mail->SMTPSecure=“tls”;
$mail->Host=SMTP\u主机//SMTP服务器
$mail->Port=25;
$mail->Username=用户名;
$mail->Password=USER\u PWD;
$mail->From=$From\u email;
$mail->FromName=$from\u name;
$mail->ContentType=“text/html”;
$mail->WordWrap=180;//设置换行符
$mail->CharSet='UTF-8';
$mail->IsHTML(true);
$mail->AddAddress($to\u add,$to\u name);
$mail->Subject=“教程获取答案”;
$HTML=“您的教程现在已经准备好,”;
$HTML.=“问题ID:”$q_id.“”;
$HTML.=“问题:”$行['description']。“”;
$HTML.=“发布日期:”$行['created_on']。“”;
$HTML.=“”;
$HTML.=“
谢谢。”;
$mail->Body=$HTML;
$mail->Send();
$msg=“将邮件发送到您的电子邮件”;
对于较小的描述,它可以正常工作,但如果描述增加,它会显示已发送的邮件,但不会显示在收件箱中。请检查并使用此格式:
$this->load->library('email');
$this->email->from('your@example.com', 'Your Name');
$this->email->to('someone@example.com');
$this->email->cc('another@another-example.com');
$this->email->bcc('them@their-example.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->set_mailtype('html');
$this->email->send();
可能这个结构会解决你的问题,因为我使用这个结构没有任何问题。$email=$this->input->post('email');
$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();
$config=Array(
'协议'=>'smtp',
'smtp_主机'=>'ssl://smtp.googlemail.com',
“smtp_端口”=>465,
'smtp_user'=>'************@gmail.com',
'smtp_pass'=>'*********',
“邮件类型”=>“html”,
“字符集”=>“utf-8”,
'wordwrap'=>TRUE
);
//将#临时通行证作为链接发送电子邮件
$this->load->library('email',$config);
$this->email->set_newline(“\r\n”);
$this->email->from('*********@gmail.com',“Name”);
$this->email->to($email);
$this->email->subject(“重置密码”);
$message=“***************”;
$message.=“***************”;
$this->email->message($message);
$this->email->send();
附上代码示例和详细错误说明。