8 use Zend\Mail\Message as MailMessage;
11 use Zend\Mime\Message as MimeMessage;
52 $this->hooks = $hooks;
53 $this->mailer = $mailer;
54 $this->logger = $logger;
66 $email = $this->hooks->trigger(
'prepare',
'system:email', null, $email);
67 if (!$email instanceof
Email) {
68 $msg =
"'prepare','system:email' hook handlers should return an instance of " .
Email::class;
77 if (!$this->hooks->trigger(
'validate',
'system:email', $hook_params, $is_valid)) {
81 return $this->transport($email);
98 if ($this->hooks->trigger(
'transport',
'system:email', $hook_params,
false)) {
111 "MIME-Version" =>
"1.0",
112 "Content-Transfer-Encoding" =>
"8bit",
121 $message->getHeaders()->addHeaderLine(
"{$name}: {$value}");
126 $body = $this->buildMessageBody($email);
128 $this->logger->error($e->getMessage());
138 $subject = html_entity_decode($subject, ENT_QUOTES,
'UTF-8');
140 $subject = preg_replace(
"/(\r\n|\r|\n)/",
" ", $subject);
141 $subject = trim($subject);
147 $message = $this->hooks->trigger(
'zend:message',
'system:email', $hook_params,
$message);
151 $ct =
$message->getHeaders()->get(
'Content-Type');
152 if ($ct instanceof ContentType) {
153 $ct->addParameter(
'format',
'flowed');
159 $this->logger->error($e->getMessage());
177 $body =
new MimeMessage();
181 $plain_text = html_entity_decode($plain_text, ENT_QUOTES,
'UTF-8');
182 $plain_text = wordwrap($plain_text);
184 $plain_text_part =
new Part($plain_text);
185 $plain_text_part->setId(
'plaintext');
186 $plain_text_part->setType(Mime::TYPE_TEXT);
187 $plain_text_part->setCharset(
'UTF-8');
189 $body->addPart($plain_text_part);
194 $body->addPart($attachement);
getTo()
Returns recipient address.
if(!$user||!$user->canDelete()) $name
elgg_strip_tags($string, $allowable_tags=null)
Strip tags and offer plugins the chance.
trait Loggable
Enables adding a logger.
transport(Email $email)
Transports an email.
$config
Advanced site settings, debugging section.
send(Email $email)
Sends an email.
getSubject()
Returns the subject.
getBody()
Returns email body.
$attachments
Outputs attachments.
buildMessageBody(Email $email)
Build the body part of the e-mail message.
getHeaders()
Returns headers.
getFrom()
Returns sender address.
__construct(Config $config, PluginHooksService $hooks, TransportInterface $mailer, LoggerInterface $logger)
Constructor.
getAttachments()
Get all attachments.