codeigniter4 sending email




In this section, we’ll see how to send email using email library.

To send the email, first we need to load the email’s service.

    $email = \Config\Services::email(); // email() is static method of Services class.

    $email->setFrom('from@example.com', 'Your Name');
    $email->setTo('to@example.com');
    $email->setCC('cc@example.com');
    $email->setBCC('bcc@example.com');
    $email->setSubject('Email Subject');
    $email->setMessage('Message');

    $email->send();

That’s it!. Please share your thoughts or suggestions in the comments below.

Leave a Reply

Your email address will not be published. Required fields are marked *