Skip to content

Commit

Permalink
Add new metadata values
Browse files Browse the repository at this point in the history
  • Loading branch information
jm-mailosaur committed Dec 2, 2021
1 parent 5620be9 commit eb70720
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
11 changes: 0 additions & 11 deletions src/Models/MessageSummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ class MessageSummary
*/
public $server;

/**
* @var MessageAddress[]
*/
public $rcpt = array();

/**
* @var MessageAddress[] The sender of the message.
*/
Expand Down Expand Up @@ -70,12 +65,6 @@ public function __construct(\stdClass $data)
$this->server = $data->server;
}

if (property_exists($data, 'rcpt') && is_array($data->rcpt)) {
foreach ($data->rcpt as $rcpt) {
$this->rcpt[] = new MessageAddress($rcpt);
}
}

if (property_exists($data, 'from') && is_array($data->from)) {
foreach ($data->from as $from) {
$this->from[] = new MessageAddress($from);
Expand Down
36 changes: 36 additions & 0 deletions src/Models/Metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,48 @@ class Metadata
/** @var \Mailosaur\Models\MessageHeader[] Email headers. */
public $headers = array();

/**
* @var string The fully-qualified domain name or IP address that was provided with the
* Extended HELLO (EHLO) or HELLO (HELO) command. This value is generally
* used to identify the SMTP client.
* https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.1.1
*/
public $mailFrom;

/**
* @var \Mailosaur\Models\MessageAddress[] The source mailbox/email address, referred to as the 'reverse-path',
* provided via the MAIL command during the SMTP transaction.
* https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.1.2
*/
public $rcptTo = array();

/**
* @var string The recipient email addresses, each referred to as a 'forward-path',
* provided via the RCPT command during the SMTP transaction.
* https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.1.3
*/
public $ehlo;

public function __construct(\stdClass $data)
{
if (property_exists($data, 'headers') && is_array($data->headers)) {
foreach ($data->headers as $header) {
$this->headers[] = new MessageHeader($header);
}
}

if (property_exists($data, 'mailFrom')) {
$this->mailFrom = $data->mailFrom;
}

if (property_exists($data, 'rcptTo') && is_array($data->rcptTo)) {
foreach ($data->rcptTo as $rcptTo) {
$this->rcptTo[] = new MessageAddress($rcptTo);
}
}

if (property_exists($data, 'ehlo')) {
$this->ehlo = $data->ehlo;
}
}
}
2 changes: 1 addition & 1 deletion tests/ServersTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function testFailedCreate()
$this->assertEquals('Request had one or more invalid parameters.', $e->getMessage());
$this->assertEquals('invalid_request', $e->errorType);
$this->assertEquals(400, $e->httpStatusCode);
$this->assertEquals('{"type":"ValidationError","messages":{"name":"Please provide a name for your server"}}', $e->httpResponseBody);
$this->assertStringContainsString('{"type":', $e->httpResponseBody);
}
}
}

0 comments on commit eb70720

Please sign in to comment.