File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed
src/main/java/com/mailersend/sdk/emails Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -388,6 +388,45 @@ public void scheduleEmail() {
388388}
389389```
390390
391+ ### Send email with list unsubscribe
392+
393+ ``` java
394+ import com.mailersend.sdk.emails.Email ;
395+ import com.mailersend.sdk.MailerSend ;
396+ import com.mailersend.sdk.MailerSendResponse ;
397+ import com.mailersend.sdk.exceptions.MailerSendException ;
398+
399+ public void sendEmailWithListUnsubscribe() {
400+
401+ Email email = new Email ();
402+
403+ email. setFrom(" name" , " your email" );
404+ email. addRecipient(" name" , " your@recipient.com" );
405+
406+ email. setSubject(" Email subject" );
407+
408+ email. setPlain(" This is the text content" );
409+ email. setHtml(" <p>This is the HTML content</p>" );
410+
411+ // Set list unsubscribe parameter that complies with RFC 8058
412+ // Note: This feature is available to Professional and Enterprise accounts only
413+ email. setListUnsubscribe(" <mailto:unsubscribe@example.com>" );
414+
415+ MailerSend ms = new MailerSend ();
416+
417+ ms. setToken(" Your API token" );
418+
419+ try {
420+
421+ MailerSendResponse response = ms. emails(). send(email);
422+ System . out. println(response. messageId);
423+ } catch (MailerSendException e) {
424+
425+ e. printStackTrace();
426+ }
427+ }
428+ ```
429+
391430### Send bulk emails
392431
393432``` java
Original file line number Diff line number Diff line change @@ -83,6 +83,9 @@ public class Email {
8383 @ SerializedName ("in_reply_to" )
8484 public String inReplyTo ;
8585
86+ @ SerializedName ("list_unsubscribe" )
87+ public String listUnsubscribe ;
88+
8689 /**
8790 * Adds a recipient to the email
8891 *
@@ -300,6 +303,17 @@ public void setInReplyTo(String inReplyTo) {
300303 this .inReplyTo = inReplyTo ;
301304 }
302305
306+ /**
307+ * Sets the list unsubscribe parameter
308+ * Accepts a single value that complies with RFC 8058
309+ * Note: This feature is available to Professional and Enterprise accounts only
310+ *
311+ * @param listUnsubscribe a {@link java.lang.String} object.
312+ */
313+ public void setListUnsubscribe (String listUnsubscribe ) {
314+ this .listUnsubscribe = listUnsubscribe ;
315+ }
316+
303317
304318 /**
305319 * Adds personalization to all recipients
You can’t perform that action at this time.
0 commit comments