Welcome Guest, Not a member yet? Register   Sign In
Email smtp: mail not send - no error
#1

I'm trying to send an e-mail from my website using the build in e-mail class and smtp. When using the mail protocol, the mail is send without incident. With smtp the mail is not send but printDebugger() doesnt show any debug information. I'm at a loss. I even went as far as simply echoing the ourput from ->send(), it seems to be empty (both with echo and print_r).

At first I used the smtp server I use to config my e-mail client. But that gave an extreme smtp timeout (even setting the SMTPTimeout vaslue to 180 didnt solve that. So I asked my host and they adviced using localhost with the settings I added below. I rather not ask them about the problem I'm facing now unless I'm certain there isn't a problem with my code. If they find a problem with my code I get charged for the support. If it's server related the support is free.

Here is the function I am writing to send the e-mail. Any insight you might have would be greatly appreciated. If you need more information, don't hesitate to ask!

PHP Code:
function sendMail($from = array(), $to = array(), $message = array(), $type 'html'$attachments false)
    {
        $config['mailType'] = $type;
        $config['protocol'] = 'smtp';
        $config['SMTPHost'] = 'localhost';
        $config['SMTPUser'] = '********@m*******ossteam.nl';
        $config['SMTPPass'] = '********';
        $config['SMTPPort'] = 587;
        $config['SMTPTimeout'] = 180;
        //$config['SMTPCrypto'] = 'ssl';
            
        $email 
= \Config\Services::email();
        $email->initialize($config);
        $email->setFrom($from['email'], $from['name']);
        $email->setTo($to['email'], $to['name']);
        $email->setSubject($message['subject']);
        $email->setMessage($message['content']);        
        
if ($email->send(false))
        {
            $email->clear();
            return true;
        }
        else
        {
            $email->printDebugger();
            exit;
        }
    
Reply


Messages In This Thread
Email smtp: mail not send - no error - by BFlokstra - 05-08-2021, 04:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB