use Friendica\App;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Hook;
+use Friendica\Core\L10n;
use Friendica\Core\PConfig\IPConfig;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Object\EMail\IEmail;
use Friendica\Protocol\Email;
+use Friendica\Util\EMailer\SystemMailBuilder;
use Psr\Log\LoggerInterface;
/**
$this->baseUrl = $baseURL;
}
+ /**
+ * Creates a new system email
+ *
+ * @param L10n $l10n The chosen language for the new email
+ *
+ * @return SystemMailBuilder
+ */
+ public function newSystemMail(L10n $l10n)
+ {
+ return new SystemMailBuilder($l10n, $this->baseUrl, $this->config);
+ }
+
/**
* Send a multipart/alternative message with Text and HTML versions
*
*/
public function send(IEmail $email)
{
- $params['sent'] = false;
-
- Hook::callAll('emailer_send_prepare', $params);
+ Hook::callAll('emailer_send_prepare', $email);
- if ($params['sent']) {
+ if (empty($email)) {
return true;
}
}
$fromName = Email::encodeHeader(html_entity_decode($email->getFromName(), ENT_QUOTES, 'UTF-8'), 'UTF-8');
- $fromEmail = $email->getFromAddress();
+ $fromAddress = $email->getFromAddress();
$replyTo = $email->getReplyTo();
$messageSubject = Email::encodeHeader(html_entity_decode($email->getSubject(), ENT_QUOTES, 'UTF-8'), 'UTF-8');
// generate a multipart/alternative message header
$messageHeader = $email->getAdditionalMailHeader() .
- "From: $fromName <{$fromEmail}>\n" .
+ "From: $fromName <{$fromAddress}>\n" .
"Reply-To: $fromName <{$replyTo}>\n" .
"MIME-Version: 1.0\n" .
"Content-Type: multipart/alternative; boundary=\"{$mimeBoundary}\"";
"--" . $mimeBoundary . "--\n"; // message ending
if ($this->config->get('system', 'sendmail_params', true)) {
- $sendmail_params = '-f ' . $fromEmail;
+ $sendmail_params = '-f ' . $fromAddress;
} else {
$sendmail_params = null;
}