Comments (7)
Is it not possible for the PHP library code to return an error instead of a fatal error. I do not want fatal errors in a production environment.
I check for returned code and if 200 then i know the email has been delivered to Mailgun.
from mailgun-php.
Go to the RestClient.php file and edit it where the error originated:
elseif($httpResponseCode == 400){
die(var_dump((string) $responseObj->getBody()));
throw new MissingRequiredParameters(EXCEPTION_MISSING_REQUIRED_PARAMETERS);
}
elseif($httpResponseCode == 401){
die(var_dump((string) $responseObj->getBody()));
throw new InvalidCredentials(EXCEPTION_INVALID_CREDENTIALS);
}
elseif($httpResponseCode == 404){
die(var_dump((string) $responseObj->getBody()));
throw new MissingEndpoint(EXCEPTION_MISSING_ENDPOINT);
}
This way you can actually see the response from the request to Mailgun. It might help you figure out what went wrong.
Mailgun should update their package to show this info in the error. I'm gonna make this a bit better looking and create a pull request.
from mailgun-php.
Turns out I had not verified my account. Got it figured out, thanks!
from mailgun-php.
You're welcome!
from mailgun-php.
Looks like the error messages were never updated. I just downloaded the SDK and got this cryptic message today. I thought I had to supply the 2nd arg to the c'tor, but that led to a whole new set of problems.
from mailgun-php.
@andrebruton You can always put a try {} catch {}
around it.
This error message should still be updated to say "This domain has not been verified yet" or something, if that is indeed the problem.
from mailgun-php.
Thank you. Tried it and I get a message back. Does this look good?
` try {
# Now, compose and send your message.
$result=$mg->sendMessage($domain, array('from' => '[email protected]',
'to' => '[email protected]',
'subject' => $subject,
'text' => $message,
'html' => $message_html
));
if ($result->http_response_code == 200) {
echo "Email Successfully Sent<br>";
echo "<pre>";
print_r($result);
echo "</pre>";
echo "Result: " . $result->http_response_code . "<p>";
} else {
echo "Error sending email<br>";
}
} catch(Exception $e) {
// Mandrill errors are thrown as exceptions
echo "Error occured: " . $e->getMessage() . "<br>";
}
`
from mailgun-php.
Related Issues (20)
- request for event microtime HOT 1
- Fatal error: Uncaught TypeError: Mailgun\Api\Domain::index() HOT 2
- Improvement: SDK version headers v2 vs v3 HOT 1
- Oudated symfony/http version HOT 3
- Bounces: The endpoint you have tried to access does not exist. HOT 2
- PHPDoc Type issue in Mailgun\Api\MailingList\Member HOT 2
- Get all lists
- TypeError: Mailgun\Api\Suppression\Bounce::show() HOT 1
- Bug: Proper json_last_error() handling with try catch
- Errors after latest update regarding json syntax HOT 2
- Error (4) when trying to json_decode response HOT 1
- Suppressions -> Bounces: cannot show for a specific address HOT 5
- Clarify effects of using php-http/discovery
- Returned data with send? HOT 1
- BCC not working properly when batch sending HOT 10
- Endpoint not correct for Tag > stats() HOT 1
- How to mock Mailgun?
- Get message from EU server?
- Feature Request: Add dkim_host_name and dkim_selector options to domains()->create() method HOT 2
- The template search filters do not match the documentation. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mailgun-php.