本文整理汇总了Java中com.mailjet.client.errors.MailjetSocketTimeoutException类的典型用法代码示例。如果您正苦于以下问题:Java MailjetSocketTimeoutException类的具体用法?Java MailjetSocketTimeoutException怎么用?Java MailjetSocketTimeoutException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MailjetSocketTimeoutException类属于com.mailjet.client.errors包,在下文中一共展示了MailjetSocketTimeoutException类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFilteringGet
import com.mailjet.client.errors.MailjetSocketTimeoutException; //导入依赖的package包/类
@Test
public void testFilteringGet() throws MailjetException, MailjetSocketTimeoutException {
MailjetClient client;
client = new MailjetClient("", "");
client.setDebug(MailjetClient.NOCALL_DEBUG);
System.out.println("TESTING: Simple Filtering with GET");
// Simple contact GET request
MailjetRequest contacts;
MailjetResponse response;
contacts = new MailjetRequest(Contact.resource)
.filter(Contact.LIMIT, 10)
.filter(Contact.OFFSET, 2);
response = client.get(contacts);
String url = response.getString("url");
Boolean test = url.equals("https://api.mailjet.com/v3/REST/contact?Offset=2&Limit=10") ||
url.equals("https://api.mailjet.com/v3/REST/contact?Limit=10&Offset=2");
assertTrue(test);
}
示例2: main
import com.mailjet.client.errors.MailjetSocketTimeoutException; //导入依赖的package包/类
public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
final String mailjetApiKey = "YOUR-MAILJET-API-KEY";
final String mailjetSecretKey = "YOUR-MAILJET-SECRET-KEY";
MailjetClient client = new MailjetClient(
mailjetApiKey, mailjetSecretKey, new ClientOptions("v3.1"));
MailjetSender sender = new MailjetSender();
sender.sendMailjet(args[0], args[1], client);
}
示例3: sendMailjet
import com.mailjet.client.errors.MailjetSocketTimeoutException; //导入依赖的package包/类
public MailjetResponse sendMailjet(String recipient, String sender, MailjetClient client)
throws MailjetException, MailjetSocketTimeoutException {
MailjetRequest email = new MailjetRequest(Emailv31.resource)
.property(Emailv31.MESSAGES, new JSONArray()
.put(new JSONObject()
.put(Emailv31.Message.FROM, new JSONObject()
.put("Email", sender)
.put("Name", "pandora"))
.put(Emailv31.Message.TO, new JSONArray()
.put(new JSONObject()
.put("Email", recipient)))
.put(Emailv31.Message.SUBJECT, "Your email flight plan!")
.put(Emailv31.Message.TEXTPART,
"Dear passenger, welcome to Mailjet! May the delivery force be with you!")
.put(Emailv31.Message.HTMLPART,
"<h3>Dear passenger, welcome to Mailjet!</h3>"
+ "<br />May the delivery force be with you!")));
try {
// trigger the API call
MailjetResponse response = client.post(email);
// Read the response data and status
System.out.println(response.getStatus());
System.out.println(response.getData());
return response;
} catch (MailjetException e) {
System.out.println("Mailjet Exception: " + e);
return null;
}
}
示例4: sendEmailWithService
import com.mailjet.client.errors.MailjetSocketTimeoutException; //导入依赖的package包/类
@Override
protected void sendEmailWithService(EmailWrapper wrapper) throws MailjetException, MailjetSocketTimeoutException {
MailjetRequest email = parseToEmail(wrapper);
MailjetClient mailjet = new MailjetClient(Config.MAILJET_APIKEY, Config.MAILJET_SECRETKEY);
MailjetResponse response = mailjet.post(email);
if (response.getStatus() != SUCCESS_CODE) {
log.severe("Email failed to send: " + response.getData().toString());
}
}
示例5: main
import com.mailjet.client.errors.MailjetSocketTimeoutException; //导入依赖的package包/类
public static void main (String[] args) throws MailjetException, MailjetSocketTimeoutException {
MailjetClient client;
MailjetRequest request;
MailjetResponse response;
client = new MailjetClient("", "");
request = new MailjetRequest(Contact.resource)
.filter(Contact.LIMIT, 10);
response = client.get(request);
System.out.println(response.getStatus());
}
示例6: testSendv3
import com.mailjet.client.errors.MailjetSocketTimeoutException; //导入依赖的package包/类
@Test
public void testSendv3() throws MailjetException, MalformedURLException, UnsupportedEncodingException, MailjetSocketTimeoutException {
MailjetClient client;
client = new MailjetClient("", "");
client.setDebug(MailjetClient.NOCALL_DEBUG);
System.out.println("TESTING: Send email with Send API v3.0");
MailjetRequest request;
MailjetResponse response;
String fromEmail = "[email protected]",
fromName = "Mailjet Pilot",
subject = "Your email flight plan!",
textPart = "Dear passenger, welcome to Mailjet! May the delivery force be with you!",
htmlPart = "<h3>Dear passenger, welcome to Mailjet</h3><br/>May the delivery force be with you!",
recipient = "[email protected]";
// Simple contact GET request
request = new MailjetRequest(Email.resource)
.property(Email.FROMEMAIL, fromEmail)
.property(Email.FROMNAME, fromName)
.property(Email.SUBJECT, subject)
.property(Email.TEXTPART, textPart)
.property(Email.HTMLPART, htmlPart)
.property(Email.RECIPIENTS, new JSONArray()
.put(new JSONObject()
.put(Email.EMAIL, recipient)));
response = client.post(request);
assertEquals(response.getString("url"), "https://api.mailjet.com/v3/send");
}
示例7: testSendv31
import com.mailjet.client.errors.MailjetSocketTimeoutException; //导入依赖的package包/类
@Test
public void testSendv31() throws MailjetException, MalformedURLException, UnsupportedEncodingException, MailjetSocketTimeoutException {
MailjetClient client;
client = new MailjetClient("", "", new ClientOptions("v3.1"));
client.setDebug(MailjetClient.NOCALL_DEBUG);
System.out.println("TESTING: Send email with Send API v3.1");
MailjetRequest request;
MailjetResponse response;
JSONObject message = new JSONObject();
message.put(Emailv31.Message.FROM, new JSONObject()
.put(Emailv31.Message.EMAIL, "[email protected]")
.put(Emailv31.Message.NAME, "Mailjet Pilot"))
.put(Emailv31.Message.SUBJECT, "Your email flight plan!")
.put(Emailv31.Message.TEXTPART, "Dear passenger, welcome to Mailjet! May the delivery force be with you!")
.put(Emailv31.Message.HTMLPART, "<h3>Dear passenger, welcome to Mailjet</h3><br/>May the delivery force be with you!")
.put(Emailv31.Message.TO, new JSONArray()
.put(new JSONObject()
.put(Emailv31.Message.EMAIL, "[email protected]")));
// Simple contact GET request
request = new MailjetRequest(Emailv31.resource).property(Emailv31.MESSAGES, (new JSONArray()).put(message));
response = client.post(request);
assertEquals(response.getString("url"), "https://api.mailjet.com/v3.1/send");
}
示例8: testEmailSend
import com.mailjet.client.errors.MailjetSocketTimeoutException; //导入依赖的package包/类
@Test
public void testEmailSend() throws MailjetException, MailjetSocketTimeoutException {
List<Person> recipients = new ArrayList<Person>() {
{
add(new Person("[email protected]", "Guillaume"));
add(new Person("[email protected]", "Arnaud"));
add(new Person("[email protected]", "Florent"));
}
};
// We create a client
MJEasyClient client = new MJEasyClient();
client.setDebug(MJEasyClient.NOCALL_DEBUG);
for (Person r : recipients) {
// Create an email
MailjetResponse response = client.email()
.from("[email protected]")
.to(r.email)
.subject("Simple proposal")
.text("Hi " + r.name + ",\n" +
"the idea is just for few very common operations to provide a higher level wrapper.\n" +
"\n-- \nFlorent")
.send(); // And send it
System.out.println(response);
Assert.assertTrue(true);
}
// This what we get:
// Response: {"Status":200,"Sent":[{"Email":"[email protected]","MessageID":16888522541389720}]}
// Response: {"Status":200,"Sent":[{"Email":"[email protected]","MessageID":18014415886981635}]}
// Response: {"Status":200,"Sent":[{"Email":"[email protected]","MessageID":18014415886982635}]}
}
示例9: testSimpleGet
import com.mailjet.client.errors.MailjetSocketTimeoutException; //导入依赖的package包/类
/**
* Test of setDebug method, of class MailjetClient.
* @throws com.mailjet.client.errors.MailjetException
*/
@Test
public void testSimpleGet() throws MailjetException, MailjetSocketTimeoutException {
MailjetClient client;
client = new MailjetClient("", "");
client.setDebug(MailjetClient.NOCALL_DEBUG);
System.out.println("TESTING: Simple GET");
// Simple contact GET request
MailjetRequest contacts;
MailjetResponse response;
contacts = new MailjetRequest(Contact.resource);
response = client.get(contacts);
assertEquals(response.getString("url"), "https://api.mailjet.com/v3/REST/contact");
}
示例10: testActionGet
import com.mailjet.client.errors.MailjetSocketTimeoutException; //导入依赖的package包/类
@Test
public void testActionGet() throws MailjetException, MalformedURLException, UnsupportedEncodingException, MailjetSocketTimeoutException {
MailjetClient client;
client = new MailjetClient("", "");
client.setDebug(MailjetClient.NOCALL_DEBUG);
System.out.println("TESTING: Simple Action with GET");
// Simple contact GET request
MailjetRequest contacts;
MailjetResponse response;
contacts = new MailjetRequest(ContactGetcontactslists.resource, existingContactID);
response = client.get(contacts);
assertEquals(response.getString("url"), "https://api.mailjet.com/v3/REST/contact/" + existingContactID + "/getcontactslists");
}
示例11: send
import com.mailjet.client.errors.MailjetSocketTimeoutException; //导入依赖的package包/类
/**
* Send the email
* @return a MailjetResponse instance
* @throws MailjetException
*/
public MailjetResponse send() throws MailjetException, MailjetSocketTimeoutException {
return client.getClient().post(request);
}