Validate domain in mg.Send()
harveysanders opened this issue · 0 comments
Hi!
I just spent some time debugging error, invalid character 'M' looking for beginning of value
, and realized my domain was incorrectly set. I later found this issue: #110
It is a silly mistake, but it may be helpful to return a clearer error message. What do you all think about validating the domain in addition to checking for an empty string? I could try to put in a PR if you all are interested. We could use a regular expression to test domain validity or maybe just check that the domain does not start with https?://
?
Line 549 in 677f15d
Thanks!
Here's more information if others run into this problem:
Error:
invalid character 'M' looking for beginning of value
Error originates from here:
Line 81 in 677f15d
Cause:
Invalid API endpoint returns a plaintext response body, where there should be JSON
curl -i --location --request POST 'https://api.mailgun.net/v3/http://mail.mydomain.com/messages' \
--header 'Authorization: Basic [API Key]' \
--form 'from="'\''Excited user mailgun@mail.mydomain.com'\
--form 'to="user@mail.org"' \
--form 'subject="'\''Hello'\
--form 'text="'\''Testing some Mailgun awesomeness!'
HTTP/1.1 200 OK
Mailgun Magnificent API