Welcome Guest, Not a member yet? Register   Sign In
$email->send() always returns false but the email is received
#4

(This post was last modified: 03-11-2020, 01:06 PM by zahhar.)

Thanks, this makes sense. Seems we have everything to troubleshoot your problem.

Email is sent through SMTP using sendWithSMTP() function declared in system/Email/Email.php class: 
https://github.com/codeigniter4/CodeIgni.../Email.php

Looks that this function can return false even if email was sent successfully! Take a look at this code (comments are mine):

PHP Code:
        $this->sendData($this->headerStr preg_replace('/^\./m''..$1'$this->finalBody));
        
$this->sendData($this->newline '.'); //finished sending body
        
$reply $this->getSMTPData(); //reads reply from SMTP server
        
$this->setErrorMessage($reply); //no idea what happens
        
$this->SMTPEnd(); //closes connection
        
if (strpos($reply'250') !== 0//reply should start with 250 only
        
{
            
$this->setErrorMessage(lang('Email.SMTPError', [$reply]));
            return 
false//this line returns FALSE even if email was sent succesfully
        


So in your case email is sent to SMTP server, but server sometimes responds with some other code then only expected code 250. Here is the full list of codes, however, particular SMTP server software may implement additional codes, or have other meaning:
https://en.wikipedia.org/wiki/List_of_SM...xx_Success

I would suggest you to debug sendWithSMTP() function by writing $reply variable values you are getting from SMTP server to log file, and then to analyze if there are any other responses then 250 (my guess will be 252 or 251, both are good candidates based on description).

If you could confirm and provide more information, we could improve this part in CI4. 

Looking forward to hearing from you.
Reply


Messages In This Thread
RE: $email->send() always returns false but the email is received - by zahhar - 03-11-2020, 01:05 PM



Theme © iAndrew 2016 - Forum software by © MyBB