custom preorder notifications: handling empty emailaddress and sending errors
This commit is contained in:
@@ -56,6 +56,9 @@ function sendPreorderEmail($mailtemplate, $preordercampaign, $preorder, $email_t
|
||||
}
|
||||
}
|
||||
|
||||
$email_to = trim($preorder->email);
|
||||
if(!$email_to) return false;
|
||||
|
||||
$subject = $mailtemplate->getVariableReplacedSubject($replacers);
|
||||
$body = '<html lang="de"><head><meta charset="utf-8" /></head><body>';
|
||||
$body .= $mailtemplate->renderBody($replacers);
|
||||
@@ -71,7 +74,7 @@ function sendPreorderEmail($mailtemplate, $preordercampaign, $preorder, $email_t
|
||||
$email->setBody($body);
|
||||
}
|
||||
$email->setFrom($preordercampaign->from_email, $preordercampaign->from_email_name);
|
||||
$email->setTo($preorder->email);
|
||||
$email->setTo($email_to);
|
||||
$email->setHeader("X-".ucfirst(MFAPPNAME)."-pid", $preorder->id);
|
||||
$email->setHeader("X-".ucfirst(MFAPPNAME)."-ps", '300-custom');
|
||||
// add attachments
|
||||
@@ -81,12 +84,15 @@ function sendPreorderEmail($mailtemplate, $preordercampaign, $preorder, $email_t
|
||||
logMessage("Adding attachment: " . $file->filename);
|
||||
$email->addAttachment($file->file->getFullPath(), null, $file->filename, $file->file->mimetype ?: null);
|
||||
}
|
||||
$email->send();
|
||||
if(!$email->send()) {
|
||||
logMessage("Error sending email for Preorder ID {$preorder->id}");
|
||||
return false;
|
||||
}
|
||||
logMessage("Email sent successfully for Preorder ID: $preorder->id, Campaign: $preordercampaign->name, Type: $email_type");
|
||||
$psn_log = PreorderStatusnotificationLog::create([
|
||||
"preorder_id" => $preorder->id,
|
||||
"email_type" => $email_type,
|
||||
"email" => $preorder->email,
|
||||
"email" => $email_to,
|
||||
]);
|
||||
$psn_log->save();
|
||||
} catch (Exception $e) {
|
||||
|
||||
Reference in New Issue
Block a user