| Line 31... |
Line 31... |
| 31 |
|
31 |
|
| 32 |
private static final Logger LOGGER = LogManager.getLogger(MailOutboxService.class);
|
32 |
private static final Logger LOGGER = LogManager.getLogger(MailOutboxService.class);
|
| 33 |
|
33 |
|
| 34 |
public static final String SENDER_SENDGRID = "SENDGRID";
|
34 |
public static final String SENDER_SENDGRID = "SENDGRID";
|
| 35 |
public static final String SENDER_GOOGLE = "GOOGLE";
|
35 |
public static final String SENDER_GOOGLE = "GOOGLE";
|
| - |
|
36 |
public static final String SENDER_RELAY = "RELAY";
|
| 36 |
|
37 |
|
| 37 |
@Value("${prod}")
|
38 |
@Value("${prod}")
|
| 38 |
private boolean prod;
|
39 |
private boolean prod;
|
| 39 |
|
40 |
|
| 40 |
/**
|
41 |
/**
|
| Line 53... |
Line 54... |
| 53 |
|
54 |
|
| 54 |
@Autowired
|
55 |
@Autowired
|
| 55 |
@Qualifier("googleMailSender")
|
56 |
@Qualifier("googleMailSender")
|
| 56 |
private JavaMailSender googleMailSender;
|
57 |
private JavaMailSender googleMailSender;
|
| 57 |
|
58 |
|
| - |
|
59 |
@Autowired
|
| - |
|
60 |
@Qualifier("gmailRelaySender")
|
| - |
|
61 |
private JavaMailSender gmailRelaySender;
|
| - |
|
62 |
|
| 58 |
// ---- Default sender (SendGrid) convenience methods ----
|
63 |
// ---- Default sender (SendGrid) convenience methods ----
|
| 59 |
|
64 |
|
| 60 |
public void queueMail(String[] emailTo, String[] cc, String subject, String body, String source) {
|
65 |
public void queueMail(String[] emailTo, String[] cc, String subject, String body, String source) {
|
| 61 |
queueMail(emailTo, cc, null, subject, body, false, source, SENDER_SENDGRID, (AttachmentData[]) null);
|
66 |
queueMail(emailTo, cc, null, subject, body, false, source, SENDER_SENDGRID, (AttachmentData[]) null);
|
| 62 |
}
|
67 |
}
|
| Line 105... |
Line 110... |
| 105 |
|
110 |
|
| 106 |
public void queueMailWithAttachmentsViaGoogle(String[] emailTo, String[] cc, String[] bcc, String subject, String body, boolean html, String source, Utils.Attachment... attachments) {
|
111 |
public void queueMailWithAttachmentsViaGoogle(String[] emailTo, String[] cc, String[] bcc, String subject, String body, boolean html, String source, Utils.Attachment... attachments) {
|
| 107 |
queueMailWithAttachments(emailTo, cc, bcc, subject, body, html, source, SENDER_GOOGLE, attachments);
|
112 |
queueMailWithAttachments(emailTo, cc, bcc, subject, body, html, source, SENDER_GOOGLE, attachments);
|
| 108 |
}
|
113 |
}
|
| 109 |
|
114 |
|
| - |
|
115 |
// ---- Google Workspace Relay sender convenience methods ----
|
| - |
|
116 |
|
| - |
|
117 |
public void queueMailViaRelay(String[] emailTo, String[] cc, String subject, String body, String source) {
|
| - |
|
118 |
queueMail(emailTo, cc, null, subject, body, false, source, SENDER_RELAY, (AttachmentData[]) null);
|
| - |
|
119 |
}
|
| - |
|
120 |
|
| - |
|
121 |
public void queueMailViaRelay(String emailTo, String[] cc, String subject, String body, String source) {
|
| - |
|
122 |
queueMail(new String[]{emailTo}, cc, null, subject, body, false, source, SENDER_RELAY, (AttachmentData[]) null);
|
| - |
|
123 |
}
|
| - |
|
124 |
|
| - |
|
125 |
public void queueMailViaRelay(String[] emailTo, String[] cc, String subject, String body, boolean html, String source) {
|
| - |
|
126 |
queueMail(emailTo, cc, null, subject, body, html, source, SENDER_RELAY, (AttachmentData[]) null);
|
| - |
|
127 |
}
|
| - |
|
128 |
|
| - |
|
129 |
public void queueMailViaRelay(String[] emailTo, String[] cc, String[] bcc, String subject, String body, boolean html, String source) {
|
| - |
|
130 |
queueMail(emailTo, cc, bcc, subject, body, html, source, SENDER_RELAY, (AttachmentData[]) null);
|
| - |
|
131 |
}
|
| - |
|
132 |
|
| - |
|
133 |
public void queueMailWithAttachmentsViaRelay(String[] emailTo, String[] cc, String subject, String body, String source, Utils.Attachment... attachments) {
|
| - |
|
134 |
queueMailWithAttachments(emailTo, cc, null, subject, body, false, source, SENDER_RELAY, attachments);
|
| - |
|
135 |
}
|
| - |
|
136 |
|
| - |
|
137 |
public void queueMailWithAttachmentsViaRelay(String[] emailTo, String[] cc, String[] bcc, String subject, String body, boolean html, String source, Utils.Attachment... attachments) {
|
| - |
|
138 |
queueMailWithAttachments(emailTo, cc, bcc, subject, body, html, source, SENDER_RELAY, attachments);
|
| - |
|
139 |
}
|
| - |
|
140 |
|
| 110 |
// ---- Internal methods ----
|
141 |
// ---- Internal methods ----
|
| 111 |
|
142 |
|
| 112 |
private void queueMailWithAttachments(String[] emailTo, String[] cc, String[] bcc, String subject, String body, boolean html, String source, String senderType, Utils.Attachment... attachments) {
|
143 |
private void queueMailWithAttachments(String[] emailTo, String[] cc, String[] bcc, String subject, String body, boolean html, String source, String senderType, Utils.Attachment... attachments) {
|
| 113 |
AttachmentData[] attachmentDataArray = null;
|
144 |
AttachmentData[] attachmentDataArray = null;
|
| 114 |
if (attachments != null && attachments.length > 0) {
|
145 |
if (attachments != null && attachments.length > 0) {
|
| Line 257... |
Line 288... |
| 257 |
|
288 |
|
| 258 |
private JavaMailSender resolveSender(String senderType) {
|
289 |
private JavaMailSender resolveSender(String senderType) {
|
| 259 |
if (SENDER_GOOGLE.equals(senderType)) {
|
290 |
if (SENDER_GOOGLE.equals(senderType)) {
|
| 260 |
return googleMailSender;
|
291 |
return googleMailSender;
|
| 261 |
}
|
292 |
}
|
| - |
|
293 |
if (SENDER_RELAY.equals(senderType)) {
|
| - |
|
294 |
return gmailRelaySender;
|
| - |
|
295 |
}
|
| 262 |
return sendgridMailSender;
|
296 |
return sendgridMailSender;
|
| 263 |
}
|
297 |
}
|
| 264 |
|
298 |
|
| 265 |
private byte[] readInputStreamSource(InputStreamSource source) throws IOException {
|
299 |
private byte[] readInputStreamSource(InputStreamSource source) throws IOException {
|
| 266 |
try (InputStream is = source.getInputStream()) {
|
300 |
try (InputStream is = source.getInputStream()) {
|