Skip to content

Commit

Permalink
Merge pull request #12 from mirko-codeplicity/master
Browse files Browse the repository at this point in the history
Change envelope field to accept clean email address
  • Loading branch information
ppavlovic committed Dec 30, 2020
2 parents e84d0e8 + fd18c0b commit 5dffe66
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Message/MailerQ/Rest/MessageFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MessageFacade
public static function convert(\G4\Mailer\Message $message, array $options)
{
$body = [
'envelope' => $message->getFrom(),
'envelope' => self::getEnvelope($message->getFrom()),
'recipient' => is_array($message->getTo())? $message->getTo()[0] : $message->getTo(),
'tags' => self::getTags($message->getHeaders()),
'inlinecss' => true,
Expand Down Expand Up @@ -50,6 +50,12 @@ public static function convert(\G4\Mailer\Message $message, array $options)
return new Message($body, $headers, $url);
}

private static function getEnvelope($string)
{
preg_match("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $string, $matches);
return $matches ? $matches[0] : htmlspecialchars($string);
}

private static function getTags($headers)
{
try {
Expand Down

0 comments on commit 5dffe66

Please sign in to comment.