Skip to content

Commit ef1bad8

Browse files
committed
Merge branch 'release/4.1.0'
2 parents c502810 + 853abfb commit ef1bad8

File tree

222 files changed

+2285
-6164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

222 files changed

+2285
-6164
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# v4.1.0
2+
## 04/09/2024
3+
4+
1. [](#improved)
5+
* Update vendor libraries for Mailer to latest `5.4` versions
6+
* When you send an email you can use `Email::getLastSendMessage()` and `Email::getLastSendDebug()` methods to get information about the email processing.
7+
18
# v4.0.4
29
## 07/10/2023
310

blueprints.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Email
22
slug: email
33
type: plugin
4-
version: 4.0.4
4+
version: 4.1.0
55
testing: false
66
description: Enables the emailing system for Grav
77
icon: envelope

classes/Email.php

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class Email
3131

3232
protected $log;
3333

34+
protected $message;
35+
protected $debug;
36+
3437
public function __construct()
3538
{
3639
$this->initMailer();
@@ -82,35 +85,31 @@ public function message(string $subject = null, string $body = null, string $con
8285
/**
8386
* Send email.
8487
*
85-
* @param Message $message
86-
* @param Envelope|null $envelope
88+
* @param Message $message
89+
* @param Envelope|null $envelope
8790
* @return int
8891
*/
8992
public function send(Message $message, Envelope $envelope = null): int
9093
{
91-
$status = '🛑 ';
92-
$sent_msg = null;
93-
$debug = null;
94-
9594
try {
9695
$sent_msg = $this->transport->send($message->getEmail(), $envelope);
97-
$return = 1;
98-
$status = '';
99-
$debug = $sent_msg->getDebug();
96+
$status = 1;
97+
$this->message = '';
98+
$this->debug = $sent_msg->getDebug();
10099
} catch (TransportExceptionInterface $e) {
101-
$return = 0;
102-
$status .= $e->getMessage();
103-
$debug = $e->getDebug();
100+
$status = 0;
101+
$this->message = '🛑 ' . $e->getMessage();
102+
$this->debug = $e->getDebug();
104103
}
105104

106105
if ($this->debug()) {
107106
$log_msg = "Email sent to %s at %s -> %s\n%s";
108107
$to = $this->jsonifyRecipients($message->getEmail()->getTo());
109-
$msg = sprintf($log_msg, $to, date('Y-m-d H:i:s'), $status, $debug);
110-
$this->log->addInfo($msg);
108+
$message = sprintf($log_msg, $to, date('Y-m-d H:i:s'), $this->message, $this->debug);
109+
$this->log->addInfo($message);
111110
}
112111

113-
return $return;
112+
return $status;
114113
}
115114

116115
/**
@@ -453,6 +452,24 @@ protected static function getTransport(): Transport\TransportInterface
453452
return $transport;
454453
}
455454

455+
/**
456+
* Get any message from the last send attempt
457+
* @return string|null
458+
*/
459+
public function getLastSendMessage(): ?string
460+
{
461+
return $this->message;
462+
}
463+
464+
/**
465+
* Get any debug information from the last send attempt
466+
* @return string|null
467+
*/
468+
public function getLastSendDebug(): ?string
469+
{
470+
return $this->debug;
471+
}
472+
456473
/**
457474
* @param array $recipients
458475
* @return string

0 commit comments

Comments
 (0)