与Laravel的Mailgun

时间:2016-08-30 03:25:39

标签: laravel mailgun

Client error response [url] https://api.mailgun.net/v3/sandboxXXXXXXXXXXXXXXXX.mailgun.org/messages.mime [status code] 400 [reason phrase] BAD REQUEST

我尝试过任何东西,但这个状态400让我陷入困境。我该怎么办呢请帮忙

1 个答案:

答案 0 :(得分:0)

只使用"来"选项避免" cc" &安培; " BCC"并尝试一下。我也坚持使用" cc" &安培; " BCC"

Client client = Client.create();
client.addFilter(new HTTPBasicAuthFilter("api", mailgun.api.key));
WebResource webResource = client.resource(mailgun.client.resource);
MultivaluedMapImpl formData = new MultivaluedMapImpl();
formData.add("from", xxxxxxxx);
formData.add("to", xxxxxxxx);
formData.add("subject", xxxxxxxx);
formData.add("html", xxxxxxxx);
webResource.type(javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED).post( ClientResponse.class, formData);

注意:更改" xxxxxxxx"使用字符串格式的有效值。

希望这会对你有所帮助。 :)