Dave
Dave

Reputation: 172

SMTP error was encountered: 555 5.5.2 Syntax error. u68sm14091815iou.0 - gsmtp

Hi i got this error when i reply an message from my inquiries

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

hello: 250-smtp.googlemail.com at your service, [122.52.95.242] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 from: 250 2.1.0 OK u68sm14091815iou.0 - gsmtp to: 555 5.5.2 Syntax error. u68sm14091815iou.0 - gsmtp The following SMTP error was encountered: 555 5.5.2 Syntax error. u68sm14091815iou.0 - gsmtp quit: 221 2.0.0 closing connection u68sm14091815iou.0 - gsmtp Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method. Date: Thu, 8 Mar 2018 13:19:44 +0100 From: Return-Path: Subject: =?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?= Reply-To: User-Agent: CodeIgniter X-Sender: [email protected] X-Mailer: CodeIgniter X-Priority: 3 (Normal) Message-ID: <[email protected]> Mime-Version: 1.0

Content-Type: multipart/alternative; boundary="B_ALT_5aa12a60a832d"

This is a multi-part message in MIME format. Your email application may not support this format.

--B_ALT_5aa12a60a832d Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit

asgfdgfdgdf

This is my controller

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("\r\n");
          $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());
    }


    }

And My view

<?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> 

Upvotes: 1

Views: 4412

Answers (1)

Andres Rave
Andres Rave

Reputation: 53

In Codeiniter4 you can use the config file (app/config/Email.php) for solve this problem. In my case I had the same answer when I was trying to set the mailing as codeiniter3 or native.

Pay atenttion to the setTo and setFrom

So go to app/config/Email.php and set like this:

<?php

namespace Config;

use CodeIgniter\Config\BaseConfig;

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 = '[email protected]';

/**
 * 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 “\r\n” to comply with RFC 822)
 *
 * @var string
 */
public $CRLF = "\r\n";

/**
 * Newline character. (Use “\r\n” to comply with RFC 822)
 *
 * @var string
 */
public $newline = "\r\n";

/**
 * 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;

}

Now, go to your line code and get something like this:

$email_user = '[email protected];
$message_html = '<h1>Hello solution</h1>';

$to = $email_user;
$subject = 'this is it';
$message = $message_html;
$email = \Config\Services::email();
$email->setTo($to);
$email->setFrom('[email protected]', '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);
}

Upvotes: 0

Related Questions