• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SMTP Mail not sending - Codeigniter Email Library

#1
Photo 
I'm having issues in sending mail through SMTP Protocol. 

**Welcome.php**

PHP Code:
$this->load->library('email');

$config = array();
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.zoho.com';
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = '**************';
$config['smtp_port'] = 465;
$config["smtp_crypto"] = "ssl";

$this->email->initialize($config);

$this->email->set_newline("\r\n");
$this->email->from('[email protected]''Support name'); // change it to yours
$this->email->to($to);// change it to yours
$this->email->subject($subject);
$this->email->message($message);

if(
$this->email->send())
{
  echo "Success! - An email has been sent to ".$to;
}
else
{
 
  show_error
($this->email->print_debugger());
  return false;
}


Here is the output error:    
Code:
An Error Was Encountered
    220 mx.zohomail.com SMTP Server ready June 29, 2018 5:16:40 AM PDT 
        
    hello: 
    
    The following SMTP error was encountered: 
    Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
    Date: Fri, 29 Jun 2018 12:16:40 +0000
    From: "Support Name" <[email protected]>
    Return-Path: <[email protected]>
    To: [email protected]
    Subject: =?ISO-8859-1?Q?=43=6F=70=79=20=61=6C=6C=20=74=68=65?=
    Reply-To: <[email protected]>
    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_5b3623284061c"
    
    This is a multi-part message in MIME format.
    Your email application may not support this format.
    
    --B_ALT_5b3623284061c
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: 8bit
    
    Some
    
    
    --B_ALT_5b3623284061c
    Content-Type: text/html; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    
    Some Email Description=0A=0A Some Email Description
    
    --B_ALT_5b3623284061c--



Quote:Note: The script is working fine on localhost, as well as multiple other hostings but not working on VPS Hosting.

These are the things to remember:

 1. The code is fine (Tried in different hosting and it works)
 2. Changing $config['protocol'] = "smtp"; to $config['protocol'] = "sendmail"; it works. But I want to send mail only through SMTP Protocol. 
 3. Using Zoho Mail SMTP Protocols (smtp.zoho.com)
 4. Tried, Google SMTP, Still not sending. (Used PHPMailer Library to test with the credentials. It's working on them.)


Attached Files Thumbnail(s)
   
Reply

#2
You need to add the SMTP server and PORT to your php.ini file.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
(06-30-2018, 06:36 AM)InsiteFX Wrote: You need to add the SMTP server and PORT to your php.ini file.

Can you describe clearly?
Reply

#4
Like I mentioned you need to edit the php.ini file usually it's in the php folder on development machines.

I use my internet providers settings like below

 [mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.comcast.net
; http://php.net/smtp-port
smtp_port = 587
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#5
(07-01-2018, 05:17 AM)InsiteFX Wrote: Like I mentioned you need to edit the php.ini file usually it's in the php folder on development machines.

I use my internet providers settings like below

 [mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.comcast.net
; http://php.net/smtp-port
smtp_port = 587

anburocky3 use $config['protocol'] = "smtp"; and not $config['protocol'] = "mail";. The config will not work... .
Reply

#6
The problem was fixed! The culprit was Valid Hostname & Reverse DNS. Thank you.
(More info here) - https://stackoverflow.com/questions/5110...6#51133416
Reply

#7
In my case I cant make it work at first using this config:]

define('SMTP','true');
define('SMTP_host','mail.example.com');
define('SMTP_user','[email protected]');
define('SMTP_pass','xxxxxxxxxxxxxxxxx');
define('SMTP_port','465');

then, I just change the port to 2.. and all are just fine now!
No SEO spam
Reply

#8
That's not a secure port number.

The port is setup in your php.ini file like I mentioned above.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.