mailgun / mailgun-php

Mailgun's Official SDK for PHP
http://www.mailgun.com
MIT License
1.09k stars 314 forks source link

Returned data with send? #892

Closed andrebruton closed 6 months ago

andrebruton commented 7 months ago

I'm trying to get feedback when sending email using the code.

$result = $mg->messages()->send('<mg.mydomain.co.za>', [
  'from'      => 'from@mydomain.co.za',
  'to'        => $users_email,
  'subject'   => $subject,
  'replyTo'   => 'reply@mydomain.co.za',
  'text'      => $text,
  'html'      => $html,
  'o:tag'     => 'testing',
  'v:usersID' => 56789
]);

echo "<pre>";
print_r($result);
echo "<pre>";

echo "Result Type: " . gettype($result), "<br>";

echo "<p>2</p>";

$message_id = $result->getId();
  echo "ID: " . $message_id . "<br>";
$message_status = $result->getMessage();
echo "Message: " . $message_status . "<br>";

I'm able to get getId() and getMessage(). I'm looking for the status code for the posting. If I get 200 I know it was posted and I can process accordingly. How do I get the return code?

What other information is available to read?

oleksandr-mykhailenko commented 6 months ago

Hello @andrebruton So In the new version we little bit extended response. And from now you can retrieve headers and status code from the response