What is the Email library in CodeIgniter 4?
Answer
CodeIgniter 4's Email class sends emails via SMTP, PHP's mail(), or Sendmail. Get the service: $email = \Config\Services::email(). Configure in app/Config/Email.php or at runtime. Usage: $email->setFrom("from@example.com", "My App")->setTo("to@example.com")->setSubject("Hello")->setMessage("<p>Body</p>")->setMailType("html")->send(). Attachments: $email->attach("/path/to/file.pdf"). CC and BCC: $email->setCC("cc@example.com"). For SMTP, configure $protocol = "smtp", $SMTPHost, $SMTPPort, $SMTPUser, $SMTPPass, and $SMTPCrypto = "tls". Debug email issues: $email->printDebugger(["headers", "subject", "body"]). Consider using a third-party service (Mailgun, SendGrid) with Guzzle for production reliability.
Previous
What is the Pagination library in CodeIgniter 4?
Next
What is CSRF protection in CodeIgniter 4?