Mail

Introduction

Exception uses PHPmailer, an email sending library based on SMTP.

Connection configuration is into env file.

You can access to it in every controller using $this->mail() or everywhere using $app->mail() (remember to include global istance compiling global $app;).

A full documentation of phpmailer is here: https://github.com/PHPMailer/PHPMailer/wiki/

Examples

New e-mail

$mail = Array(
   "subject" => "Test mail",
   "body" => "HTML here"
);
$this->mail->addAddress("[email protected]");
$this->mail->Subject = $mail["subject"];
$this->mail->Body = $mail["body"];
$this->mail->isHTML(true);
$this->mail->send();
$this->mail->ClearAllRecipients();


CC and BCC

$mail = Array(
   "subject" => "Test mail",
   "body" => "HTML here"
);
$this->mail->addAddress("[email protected]");
$this->mail->AddCC("[email protected]", "cc address");
$this->mail->AddBCC("[email protected]", "bcc address");
$this->mail->Subject = $mail["subject"];
$this->mail->Body = $mail["body"];
$this->mail->isHTML(true);
$this->mail->send();
$this->mail->ClearAllRecipients();


Send Attachments

$mail = Array(
   "subject" => "Test mail",
   "body" => "HTML here"
);
$this->mail->addAddress("[email protected]");
$this->mail->Subject = $mail["subject"];
$this->mail->Body = $mail["body"];
$this->mail->isHTML(true);
$this->mail->addAttachment("uploads/".$file_name1);
$this->mail->addAttachment("uploads/".$file_name2);
$this->mail->addAttachment("uploads/".$file_name3);
$this->mail->send();
$this->mail->ClearAllRecipients();

Do you need help?

Write me an e-mail: [email protected]