X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FEmailer.php;h=1dd513c42fe3f1c10b19b390508ff60edec95858;hb=dc49ad090eca1bf4e511091418166da6fe68009b;hp=a2be983d6c03cb7ca78645831b5b836639161700;hpb=2d6ee38446380ec3bc65b6158ba7e013ac92748e;p=friendica.git diff --git a/src/Util/Emailer.php b/src/Util/Emailer.php index a2be983d6c..1dd513c42f 100644 --- a/src/Util/Emailer.php +++ b/src/Util/Emailer.php @@ -4,12 +4,13 @@ */ namespace Friendica\Util; +use Friendica\Core\Addon; +use Friendica\Core\Config; use Friendica\Core\PConfig; - -require_once 'include/email.php'; +use Friendica\Protocol\Email; /** - * @breif class to handle emailing + * @brief class to handle emailing */ class Emailer { @@ -31,15 +32,15 @@ class Emailer */ public static function send($params) { - call_hooks('emailer_send_prepare', $params); + Addon::callHooks('emailer_send_prepare', $params); $email_textonly = false; if (x($params, "uid")) { $email_textonly = PConfig::get($params['uid'], "system", "email_textonly"); } - $fromName = email_header_encode(html_entity_decode($params['fromName'], ENT_QUOTES, 'UTF-8'), 'UTF-8'); - $messageSubject = email_header_encode(html_entity_decode($params['messageSubject'], ENT_QUOTES, 'UTF-8'), 'UTF-8'); + $fromName = Email::encodeHeader(html_entity_decode($params['fromName'], ENT_QUOTES, 'UTF-8'), 'UTF-8'); + $messageSubject = Email::encodeHeader(html_entity_decode($params['messageSubject'], ENT_QUOTES, 'UTF-8'), 'UTF-8'); // generate a mime boundary $mimeBoundary =rand(0, 9)."-" @@ -48,7 +49,7 @@ class Emailer .rand(10000, 99999); // generate a multipart/alternative message header - $messageHeader = $params['additionalMailHeader'] . + $messageHeader = defaults($params, 'additionalMailHeader', '') . "From: $fromName <{$params['fromEmail']}>\n" . "Reply-To: $fromName <{$params['replyTo']}>\n" . "MIME-Version: 1.0\n" . @@ -72,20 +73,28 @@ class Emailer $multipartMessageBody .= "--" . $mimeBoundary . "--\n"; // message ending + if (Config::get("system", "sendmail_params", true)) { + $sendmail_params = '-f ' . $params['fromEmail']; + } else { + $sendmail_params = null; + } + // send the message - $hookdata = array( + $hookdata = [ 'to' => $params['toEmail'], 'subject' => $messageSubject, 'body' => $multipartMessageBody, - 'headers' => $messageHeader - ); + 'headers' => $messageHeader, + 'parameters' => $sendmail_params + ]; //echo "
"; var_dump($hookdata); killme(); - call_hooks("emailer_send", $hookdata); + Addon::callHooks("emailer_send", $hookdata); $res = mail( - $hookdata['to'], // send to address - $hookdata['subject'], // subject - $hookdata['body'], // message body - $hookdata['headers'] // message headers + $hookdata['to'], + $hookdata['subject'], + $hookdata['body'], + $hookdata['headers'], + $hookdata['parameters'] ); logger("header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, LOGGER_DEBUG); logger("return value " . (($res)?"true":"false"), LOGGER_DEBUG);