Welcome Guest, Not a member yet? Register   Sign In
SMTP Email
#1

Hi,

I am having a problem using the CI4 built in email class.

I have stepped through in the debugger and get as far as 

PHP Code:
$this->sendCommand('starttls'); 

in the SMTPConnect function.

It then throws an error 

"fwrite(): send of 10 bytes failed with errno=32 Broken pipe"

It seems that the login is successful in terms of connecting to the host and it accepting my username and password.

Speaking with the hosting provider, they confirmed that SSL or TLS should work correctly. However, I have not been able to send email with either.

My sending code is very simple:

PHP Code:
    public function email_send()
    {
        
$email = \Config\Services::email();

        
$email->setFrom('[email protected]''Tester');
        
$email->setTo('[email protected]');


        
$email->setSubject('Email Test');
        
$email->setMessage('Testing the email class.');

        
$res $email->send(false);

        if (
$res)
        {
            echo 
'Email send was successful';
        }
        else
        {
            echo 
'Failed to send the email';
            
print_r($email->printDebugger());
        }

    } 
// end of method 

Obviously the email addresses are bogus, I changed them from real addresses.

The code doesn't get as far as the failed block on the return due to the exception mentioned above.

The config file is, stripped of comment, to make it shorter:


PHP Code:
    public $fromEmail;
    public 
$fromName;
    public 
$recipients;
    public 
$userAgent 'CodeIgniter';
    public 
$protocol 'smtp';
    public 
$mailPath '/usr/sbin/mhsendmail';
    public 
$SMTPHost 'host.co.uk';
    public 
$SMTPUser '******';
    public 
$SMTPPass '******';
    public 
$SMTPPort 465;
    public 
$SMTPTimeout 5;
     public 
$SMTPKeepAlive false;
    public 
$SMTPCrypto 'tls';
    public 
$wordWrap true;
    public 
$wrapChars 76;
    public 
$mailType 'text';
    public 
$charset 'UTF-8';
    public 
$validate false;
    public 
$priority 3;
    public 
$CRLF "\r\n";
    public 
$newline "\r\n";
    public 
$BCCBatchMode false;
    public 
$BCCBatchSize 200;
    public 
$DSN false

I am looking for any help on this process.

Yes, the sendmail path is from testing with MailHog on my Mac. And that works with the 'mail' protocol. It works from the server too. But it isn't a good long term solution. I would rather have the function of smtp.

Thanks.
Reply


Messages In This Thread
SMTP Email - by Chroma - 07-30-2020, 09:38 AM
RE: SMTP Email - by tgix - 07-30-2020, 12:39 PM
RE: SMTP Email - by Chroma - 07-30-2020, 01:26 PM
RE: SMTP Email - by tgix - 07-30-2020, 09:27 PM
RE: SMTP Email - by Chroma - 07-30-2020, 11:11 PM
RE: SMTP Email - by tgix - 07-31-2020, 12:43 AM
RE: SMTP Email - by Chroma - 08-09-2020, 01:40 AM
RE: SMTP Email - by tgix - 08-09-2020, 02:09 AM
RE: SMTP Email - by Chroma - 08-09-2020, 09:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB