Comments (8)
PS.: I forgot to mention: my development tomcat is running with SSL using a self signed cert. Previously I had to import your GoDaddy cert (*.mailjet.com) into my keystore due a handshake problem.
from mailjet-apiv3-java.
Hey @anaice !
Can you try to paste the output of the debug mode here ?
To enable it: client.setDebug(MailjetClient.VERBOSE_DEBUG)
Thanks 👍
from mailjet-apiv3-java.
Hi @GuillaumeBadi
Nice hint.
=== HTTP Request ===
POST https://api.mailjet.com/v3/send
Accept-Charset:UTF-8
user-agent:mailjet-apiv3-java/v3.0.0
Content-Type:application/json
Accept:application/json
=== HTTP Response ===
Receive url: https://api.mailjet.com/v3/send
Status: 400
null:HTTP/1.1 400 Invalid characters detected
Date:Tue, 01 Mar 2016 11:25:17 GMT
Vary:Accept-Encoding
Content-Length:0
Content-Type:text/html
Connection:keep-alive
Server:nginx
Content:
null
I just noted my:
email = new MailjetRequest(Email.resource) .property(Email.FROMNAME, "Teste")
is actually
email = new MailjetRequest(Email.resource) .property(Email.FROMNAME, "Equipe NetCaçambas")
So i think the problem here is my ç character. When I remove it my email is sent.
Same code running with JUnit (using ç character):
=== HTTP Request ===
POST https://api.mailjet.com/v3/send
Accept-Charset:UTF-8
user-agent:mailjet-apiv3-java/v3.0.0
Content-Type:application/json
Accept:application/json
=== HTTP Response ===
Receive url: https://api.mailjet.com/v3/send
Status: 200
null:HTTP/1.1 200 OK
Date:Tue, 01 Mar 2016 11:35:13 GMT
Content-Length:90
Connection:keep-alive
Content-Type:application/json
Server:nginx
Content:
{ "Sent" : [{ "Email" : "[email protected]", "MessageID" : 19421806538239714 }] }
Merci Beaucoup!
from mailjet-apiv3-java.
I guess it is a matter of encoding. the default String encoding in Java is utf16. It needs to be converted in utf8. I still don't know why but it works on my local environment, I cant reproduce the error locally.
from mailjet-apiv3-java.
You are right @GuillaumeBadi
When I force a conversion and it works.
`
(...)
MailjetClient client = new MailjetClient("_", "_");
client.setDebug(MailjetClient.VERBOSE_DEBUG);
MailjetRequest email;
JSONArray recipients;
MailjetResponse response;
recipients = new JSONArray()
.put(new JSONObject().put(Contact.EMAIL, "[email protected]"));
try {
email = new MailjetRequest(Email.resource)
.property(Email.FROMNAME, convertToUTF8("Equipe NetCaçambas"))
.property(Email.FROMEMAIL, "[email protected]")
.property(Email.SUBJECT, "Testando")
.property(Email.HTMLPART, convertToUTF8("<html> <body> <h1>Teste</h1> <p>NetCaçambas Software</p></body> </html>"))
.property(Email.RECIPIENTS, recipients);
response = client.post(email);
} catch (MailjetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
(...)
/**
* convert from internal Java String format -> UTF-8
* From: https://fabioangelini.wordpress.com/2011/08/04/converting-java-string-fromto-utf-8/
* @param s
* @return
*/
public static String convertToUTF8(String s) {
String out = null;
try {
out = new String(s.getBytes("UTF-8"), "ISO-8859-1");
} catch (java.io.UnsupportedEncodingException e) {
return null; // =~
}
return out;
}
`
Debug Msgs:
=== HTTP Request ===
POST https://api.mailjet.com/v3/send
Accept-Charset:UTF-8
user-agent:mailjet-apiv3-java/v3.0.0
Content-Type:application/json
Accept:application/json
=== HTTP Response ===
Receive url: https://api.mailjet.com/v3/send
Status: 200
null:HTTP/1.1 200 OK
Date:Tue, 01 Mar 2016 16:37:14 GMT
Content-Length:90
Content-Type:application/json
Connection:keep-alive
Server:nginx
Content:
{ "Sent" : [{ "Email" : "[email protected]", "MessageID" : 20547703824686000 }] }
I just don't get why my JUnit works without any conversion.
Anyway, I will work with conversions to use the api.
Thank you!
from mailjet-apiv3-java.
It seems to be an issue only from webapps.
Thanks for finding this. I am going to add it in the readme
from mailjet-apiv3-java.
Hey, you might be interested: https://github.com/mailjet/mailjet-apiv3-java/releases/tag/v3.1.0 :)
from mailjet-apiv3-java.
Coool =D
Thanks.
from mailjet-apiv3-java.
Related Issues (20)
- Release 5.2.1 not tagged and not published to maven HOT 5
- Cannot access Client Options
- Constant for "Globals" missing in Emailv31. HOT 1
- Send Mail With JDK11 HttpClient? HOT 1
- CVE-2020-29582: Information exposure HOT 1
- Csvimport.DATA does not exist HOT 2
- java.lang.NoSuchMethodError: kotlin.collections.ArraysKt.copyInto([B[BIII)[B HOT 6
- Certificate issue HOT 1
- Patch org.json:json@20220320 to fix CVE-2022-45688 HOT 1
- com.mailjet.client.errors.MailjetUnauthorizedException: Unauthorized HOT 1
- Contactstatistics: JSONException: JSONObject["Contact"] not found. HOT 2
- Message Result 'To' is null HOT 2
- Passing variables to templates does not work.
- Socket Exception HOT 2
- New vulnerability in org.json (https://nvd.nist.gov/vuln/detail/CVE-2023-5072#VulnChangeHistorySection) HOT 1
- SocketTimeoutException HOT 1
- delete customer 401 Unauthorized HOT 1
- update customer by ID 404
- Certificate Issue
- 429 errors should get a http header in the response with timestamp for the next time slot
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 mailjet-apiv3-java.