added email from

This commit is contained in:
asus
2024-04-10 22:31:43 +02:00
parent 265664537e
commit 6ecffc25f7
4 changed files with 70 additions and 12 deletions

View File

@@ -38,7 +38,7 @@ function prepare_emails_CIPF($email_name, $user_id) {
}
$user = get_user_by('id', $user_id);
$user_email = $user->user_email;
$headers = array('Content-Type: text/html; charset=UTF-8');
$header_content_type = 'Content-Type: text/html; charset=UTF-8';
$emails_option = Plgntls::get_option_safe($emails_option_object);
@@ -57,7 +57,15 @@ function prepare_emails_CIPF($email_name, $user_id) {
$tmp_email['to'] = $email['notification_to'];
$tmp_email['subject'] = $email['notification_subject'];
$tmp_email['message'] = $email['notification_message'];
$tmp_email['headers'] = $headers;
$tmp_email['headers'] = array();
$tmp_email['headers'][] = $header_content_type;
$from = $email['notification_from'];
if (empty($from)) {
$from = get_option('admin_email');
}
if (!empty($from)) {
$tmp_email['headers'][] = 'From:'.$from;
}
$emails[] = $tmp_email;
}
if ($email['confirmation_send']) {
@@ -65,7 +73,15 @@ function prepare_emails_CIPF($email_name, $user_id) {
$tmp_email['to'] = $user_email;
$tmp_email['subject'] = $email['confirmation_subject'];
$tmp_email['message'] = $email['confirmation_message'];
$tmp_email['headers'] = $headers;
$tmp_email['headers'] = array();
$tmp_email['headers'][] = $header_content_type;
$from = $email['confirmation_from'];
if (empty($from)) {
$from = get_option('admin_email');
}
if (!empty($from)) {
$tmp_email['headers'][] = 'From:'.$from;
}
$emails[] = $tmp_email;
}
return $emails;
@@ -82,6 +98,7 @@ function send_emails_CIPF($email_name, $user_id = null) {
}
foreach ($emails as $email) {
error_log('Email: ' . json_encode($email));
$sent = wp_mail($email['to'], $email['subject'], $email['message'], $email['headers']);
}
if (!$sent) {