使用CodeIgniter发送邮件时 - SMTP显示以下错误。但邮件到达目的地。由于错误,我无法在客户端显示自定义消息。我与服务器端团队联系,但他们告诉我在我的代码中的问题。但我找不到任何东西。
这是一种HTML类型的邮件
我的代码如下所示
$from_mail = "contest@mytechnopark.in";
$subject = "My Technopark Contest - ".$contest_title;
$to_mail = trim($user_mail);//$data['user_mail'];
$mail_template = '<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Technopark</title>
</head>
<body>
<table width="600" align="center">
<tbody>
<tr>
<td style="font-size:18px;color:#000;font-family:Arial;"><br>
<span style="font-size:18px;font-family:Arial;font-weight:100; line-height:22px;">
<p><img src="http://www.mytechnopark.in/email-temp/xmas.jpg"> </p>
<p><h4><strong> Hai '.$user_name.',</strong></h4></p>
</span>
<p>
<h4><strong>Thanks and Regards,</strong></h4>
</p>
<h4><strong> Team</strong></h4>
</span>
</td>
</tr>
<tr>
<td style="font-family:Arial;font-size:13px; text-align:center; color:#666; padding:6px 0; background:#ccc" >
</td>
</tr>
</tbody>
</table>
</body>
</html>';
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'mail.mypark.in';
$config['smtp_port'] = '25';
$config['smtp_timeout'] = '7';
$config['smtp_user'] = 'info@mypark.in';
$config['smtp_pass'] = '**************';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['mailtype'] = 'html'; // or html
$config['validation'] = TRUE; // bool whether to validate email or not
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$this->email->from($from_mail,'Title');
$this->email->to($to_mail);
$this->email->subject($subject);
$this->email->message($mail_template);
$this->email->set_mailtype('html');
if($this->email->send()){
$result = $this->Contest_Model->send_email_db($apply_id);
json_encode($this->response($result,200));
}else{
echo $this->email->print_debugger();
json_encode($this->response(array("result"=>0,"message"=>"Mail sent failed"),200));
}
错误显示在下方
220-cp-34.webhostbox.net ESMTP Exim 4.89 #1 Fri, 22 Dec 2017 04:08:47 +0000
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
<br /><pre>hello: 250-cp-34.webhostbox.net Hello www.mypark.in [127.0.0.1]
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
</pre><pre>from: 250 OK
</pre><pre>to: 250 Accepted
</pre><pre>data: 354 Enter message, ending with "." on a line by itself
</pre><br /><pre>quit: 250 OK id=1eSEdb-001tEE-Hg
</pre>The following SMTP error was encountered: 250 OK id=1eSEdb-001tEE-Hg
<br />The following SMTP error was encountered: <br />Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.<br /><pre>Date: Fri, 22 Dec 2017 09:38:47 +0530
From: "My park" <info@mypark.in>
Return-Path: <info@mypark.in>
To: rahul.pra@gmail.com
Subject: =?UTF-8?Q?Thank=20you?=
Reply-To: <info@mypark.in>
User-Agent: CodeIgniter
X-Sender: info@mytpark.in
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <5a3c854f7f5ad@mypark.in>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_5a3c854f7f602"
This is a multi-part message in MIME format.
Your email application may not support this format.
--B_ALT_5a3c854f7f602
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Hai Jijith,
Regards,
Team Mypark
答案 0 :(得分:0)
此smtp示例适用于2017年,并使用SMTP发送电子邮件
https://github.com/dataf3l/curso-php-2017/blob/master/contact-form/mail.php
考虑修改php.ini并设置邮件项目。