遇到 SMTP 错误:555 5.5.2 语法错误. u68sm14091815iou.0 - gsmtp.



嗨,当我回复查询中的消息时,我收到此错误

220 smtp.googlemail.com ESMTP u68sm14091815iou.0 - GSMTP

您好: 250-smtp.googlemail.com 为您服务 [122.52.95.242] 250 大小35882577 250-8BITMIME 250-身份验证登录普通XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-enhancedstatuscodes 250流水线 250分块 250 SMTPUTF8来自: 250 2.1.0 OK u68sm14091815iou.0 - gsmtp 至: 555 5.5.2 语法错误。 u68sm14091815iou.0 - gsmtp 遇到以下 SMTP 错误: 555 5.5.2 语法错误。U68SM14091815IU.0 - GSMTP 退出: 221 2.0.0 关闭连接 u68sm14091815iou.0 - gsmtp 无法发送电子邮件 使用 PHP SMTP。您的服务器可能未配置为使用 此方法。日期:2018 年 3 月 8 日星期四 13:19:44 +0100 来自: 返回路径: 主题: =?ISO-8859-1?Q?=43=65=62=75=20=48=65=72=62=73=20=49=6E=71=75=69=72=69=65?= =?ISO-8859-1?Q?=73?= 回复:用户代理:代码点火器 X-发送者:cebuherbs1@gmail.com X-邮件:代码点火器 X 优先级:3(正常) 邮件 ID:<5aa12a60a8321@gmail.com>MIME 版本:1.0

内容类型:多部分/替代;边界="B_ALT_5aa12a60a832d">

这是 MIME 格式的多部分邮件。您的电子邮件申请 可能不支持此格式。

--B_ALT_5aa12a60a832d 内容类型:文本/纯文本;字符集=ISO-8859-1 内容传输编码:8 位

asgfdgfdgdf

这是我的控制器

public function reply_inquiries()
{
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '*******@gmail.com',
'smtp_pass' => '********',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$message = $this->input->post('message');
$this->load->library('email', $config);
$this->email->set_newline("rn");
$this->email->from('********@gmail.com');
$this->email->to($this->input->post('email'));
$this->email->subject('Cebu Herbs Inquiries');
$this->email->message($message);
if($this->email->send())
{
echo 'Email sent.';
}
else
{
show_error($this->email->print_debugger());
}

}

和我的观点

<?php echo form_open('admin/reply_inquiries',['class'=>'col s8']);?>
<div id="page-wrapper" >
<div class="header"> 
<h1 class="page-header">
Reply Inquiries
</h1>
<ol class="breadcrumb">
<li><a href="<?php echo base_url('admin'); ?>">Home</a></li>
<li><a href="<?php echo base_url('admin/inquiries_view'); ?>">Inquiries</a></li>
<li class="active">Reply Inquiries</li>
</ol> 
</div>
<div id="page-inner"> 
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-action">
Reply
</div>
<div class="card-content">
<div class="row">
<div class="input-field col s4">
<i class="material-icons prefix">email</i>
<input name="product_name" type="text" class="validate">
<label for="email">E-mail</label>
</div>
</div>
<form class="col s6">
<div class="row">
<div class="input-field col s4">
<i class="material-icons prefix">mode_edit</i>
<textarea name="message" class="materialize-textarea"></textarea>
<label for="message">Message</label>
</div>
</div>
</form>
<div class="row">
<div class="col s4">
<div class="col-md-10 col-md-offset-2">
<button type="submit" class="btn btn-success">Reply
<i class="material-icons right">send</i>
</button> 
</div>
</div>
</div>
<?php echo form_close(); ?>
</div>
</div>
</div> 
</div> 

在 Codeiniter4 中,您可以使用配置文件(app/config/Email.php)来解决此问题。就我而言,当我尝试将邮件设置为 codeiniter3 或本机时,我得到了相同的答案。

向设置到和设置从支付保留

因此,请转到应用程序/配置/电子邮件.php并像这样设置:

<?php
namespace Config;
use CodeIgniterConfigBaseConfig;
class Email extends BaseConfig
{
/**
* @var string
*/
public $fromEmail;
/**
* @var string
*/
public $fromName;
/**
* @var string
*/
public $recipients;
/**
* The "user agent"
*
* @var string
*/
public $userAgent = 'CodeIgniter';
/**
* The mail sending protocol: mail, sendmail, smtp
*
* @var string
*/
public $protocol = 'smtp';
/**
* The server path to Sendmail.
*
* @var string
*/
public $mailPath = '/usr/sbin/sendmail';
/**
* SMTP Server Address
*
* @var string
*/
public $SMTPHost = 'smtp.googlemail.com';
/**
* SMTP Username
*
* @var string
*/
public $SMTPUser = 'myemail@gmail.com';
/**
* SMTP Password
*
* @var string
*/
public $SMTPPass = 'pass**';
/**
* SMTP Port
*
* @var integer
*/
public $SMTPPort = 465;
/**
* SMTP Timeout (in seconds)
*
* @var integer
*/
public $SMTPTimeout = 60;
/**
* Enable persistent SMTP connections
*
* @var boolean
*/
public $SMTPKeepAlive = false;
/**
* SMTP Encryption. Either tls or ssl
*
* @var string
*/
public $SMTPCrypto = 'ssl';
/**
* Enable word-wrap
*
* @var boolean
*/
public $wordWrap = true;
/**
* Character count to wrap at
*
* @var integer
*/
public $wrapChars = 76;
/**
* Type of mail, either 'text' or 'html'
*
* @var string
*/
public $mailType = 'html';
/**
* Character set (utf-8, iso-8859-1, etc.)
*
* @var string
*/
public $charset = 'UTF-8';
/**
* Whether to validate the email address
*
* @var boolean
*/
public $validate = false;
/**
* Email Priority. 1 = highest. 5 = lowest. 3 = normal
*
* @var integer
*/
public $priority = 3;
/**
* Newline character. (Use “rn” to comply with RFC 822)
*
* @var string
*/
public $CRLF = "rn";
/**
* Newline character. (Use “rn” to comply with RFC 822)
*
* @var string
*/
public $newline = "rn";
/**
* Enable BCC Batch Mode.
*
* @var boolean
*/
public $BCCBatchMode = false;
/**
* Number of emails in each BCC batch
*
* @var integer
*/
public $BCCBatchSize = 200;
/**
* Enable notify message from server
*
* @var boolean
*/
public $DSN = false;
}

现在,转到您的行代码并得到如下所示的内容:

$email_user = 'myemail@gmail.com;
$message_html = '<h1>Hello solution</h1>';
$to = $email_user;
$subject = 'this is it';
$message = $message_html;
$email = ConfigServices::email();
$email->setTo($to);
$email->setFrom('myemail@gmail.com', 'Hey! here is the solution');
$email->setSubject($subject);
$email->setMessage($message);
if ($email->send()) 
{
echo 'Email successfully sent';
} 
else 
{
$data = $email->printDebugger(['headers']);
print_r($data);
}

最新更新