send email dan daily monitoring

This commit is contained in:
2023-12-25 09:52:03 +07:00
parent 40371bd53a
commit 5a439922d9
7 changed files with 233 additions and 14 deletions

View File

@@ -317,7 +317,6 @@ class Helper
{
// Buat instance PHPMailer
$mail = new PHPMailer(true);
try {
// Server settings
$mail->isSMTP();
@@ -341,8 +340,46 @@ class Helper
// Kirim email
$mail->send();
return true;
} catch (\Exception $e) {
//var_dump($mail->ErrorInfo);die();
dd($e);
return ($mail->ErrorInfo);
return false;
}
}
public static function sendEmailattachData($data = array())
{
// Buat instance PHPMailer
$mail = new PHPMailer(true);
try {
// Server settings
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = env('EMAIL');
$mail->Password = env('PW_EMAIL');
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 465;
$mail->SMTPSecure = "ssl";
// Penerima email
$mail->setFrom(env('EMAIL'), env('NAME_EMAIL'));
$mail->addAddress($data['email'], $data['name']);
// Konten email
$mail->isHTML(true);
$mail->Subject = $data['subject'];
$mail->Body = $data['body'];
$mail->addAttachment($data['attach'], 'e-card.pdf');
// Kirim email
$mail->send();
return true;
} catch (\Exception $e) {
dd($mail->ErrorInfo);
return ($mail->ErrorInfo);
return false;
}
}