简体   繁体   中英

Am trying to send a message on Codeigniter 4 but i keep having this error

public function send_mail()
{
    $email = \Config\Services::email();

    $config['protocol'] = 'smtp';
    $config['SMTPHost'] = 'smtp.mailtrap.io';
    $config['SMTPUser'] = '[obscured]';
    $config['SMTPPass'] = '[obscured]';
    $config['SMTPPort'] = 25;
    $config['SMTPCrypto'] = 'tls';
    $config['mailType'] = 'html';
    $config['charset'] = 'utf-8';
    $config['newline'] = "\r\n";


    $email->initialize($config);

    $email->setFrom('bra0@gmail.com', 'Brainyworld');
    $email->setTo('usm@gmail.com');

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

    $email->send(false);
    echo $email->printDebugger(['header']);


        }

and here is the error am having

hello: The following SMTP error was encountered: starttls: 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.

通过将我的 SMTPPort 从 25 更改为 2525 并且我的消息开始发送,我能够解决这个问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM