public class MailManagerImpl extends Object implements MailManager
Modifier and Type | Field and Description |
---|---|
static String |
LINE_BEFORE_PASSWORD_IN_LOGS |
static String |
SANITISED_PASSWORD |
Constructor and Description |
---|
MailManagerImpl(InternalPropertyManager propertyManager,
com.atlassian.sal.api.ApplicationProperties applicationProperties,
ClusterService clusterService,
Clock clock,
I18nHelper i18nHelper,
MailSendManager sendManager,
AuthenticatedUserProvider authenticatedUserProvider) |
Modifier and Type | Method and Description |
---|---|
MailConfiguration |
getMailConfiguration()
Returns current mail configuration
|
boolean |
isConfigured() |
protected String |
removePasswordFromLogs(String logs) |
void |
saveConfiguration(MailConfiguration mailConfiguration)
Sets the new mail configuration
|
Set<? extends EmailMessage> |
sendEmails(Collection<? extends EmailMessage> messagesToSend)
Sends multiple emails using the configured mail server.
|
void |
sendHtmlEmail(javax.mail.internet.InternetAddress emailAddress,
String subject,
String body,
String plainText)
Sends an HTML email using the configured mail server (remote host / JNDI).
|
void |
sendPlainTextEmail(javax.mail.internet.InternetAddress emailAddress,
String subject,
String body)
Sends an email using the configured mail server (remote host / JNDI).
|
void |
sendPlainTextEmail(javax.mail.internet.InternetAddress emailAddress,
String subject,
String body,
Map<String,String> headers,
Map<String,DataSource> attachments)
Sends an email with zero or more attachments and headers using the configured mail server (remote host / JNDI).
|
SendTestMailResult |
sendTestMail(SMTPServer smtpServer,
javax.mail.internet.InternetAddress emailAddress)
Send a test email using the supplied mail server (remote host / JNDI)
|
List<ValidationError> |
validateConfiguration(MailConfiguration mailServerEntity)
Verifies whether the specified MailConfiguration is valid
|
public static final String SANITISED_PASSWORD
public static final String LINE_BEFORE_PASSWORD_IN_LOGS
public MailManagerImpl(InternalPropertyManager propertyManager, com.atlassian.sal.api.ApplicationProperties applicationProperties, ClusterService clusterService, Clock clock, I18nHelper i18nHelper, MailSendManager sendManager, AuthenticatedUserProvider authenticatedUserProvider)
public void sendHtmlEmail(javax.mail.internet.InternetAddress emailAddress, String subject, String body, String plainText) throws MailSendException
MailManager
sendHtmlEmail
in interface MailManager
emailAddress
- address of recipient.subject
- subject header.
Will be appended with the configured mail subject prefix in the final email.body
- email body html.plainText
- plainText alternative to the html body text specified in body
MailSendException
- an error occured sending the email.public void sendPlainTextEmail(javax.mail.internet.InternetAddress emailAddress, String subject, String body) throws MailSendException
MailManager
sendPlainTextEmail
in interface MailManager
emailAddress
- address of recipient.subject
- subject header.
Will be appended with the configured mail subject prefix in the final email.body
- email body text.MailSendException
- an error occured sending the email.public void sendPlainTextEmail(javax.mail.internet.InternetAddress emailAddress, String subject, String body, Map<String,String> headers, Map<String,DataSource> attachments) throws MailSendException
MailManager
sendPlainTextEmail
in interface MailManager
emailAddress
- address of recipient.subject
- subject header.
Will be appended with the configured mail subject prefix in the final email.body
- email body text.headers
- custom headers to add.attachments
- [displayed filename]->[data] mapping for attachments.MailSendException
- an error occured sending the email.public SendTestMailResult sendTestMail(SMTPServer smtpServer, javax.mail.internet.InternetAddress emailAddress) throws MailSendException
MailManager
sendTestMail
in interface MailManager
smtpServer
- supplied SMTP Server, which will be used to send message.emailAddress
- address of recipient.MailSendException
- an error occured sending the email.public Set<? extends EmailMessage> sendEmails(Collection<? extends EmailMessage> messagesToSend) throws MailSendException
MailManager
sendEmails
in interface MailManager
MailSendException
- an error occurred that prevented sending any email (connection error, configuration error, etc.).public List<ValidationError> validateConfiguration(MailConfiguration mailServerEntity)
MailManager
validateConfiguration
in interface MailManager
mailServerEntity
- entity with attributes to be validatedpublic void saveConfiguration(MailConfiguration mailConfiguration)
MailManager
saveConfiguration
in interface MailConfigurationService
saveConfiguration
in interface MailManager
mailConfiguration
- new configurationpublic MailConfiguration getMailConfiguration()
MailManager
getMailConfiguration
in interface MailConfigurationService
getMailConfiguration
in interface MailManager
public boolean isConfigured()
isConfigured
in interface MailConfigurationService
isConfigured
in interface MailManager
true
if the mail server is fully configured (does not check if the configuration is correct)Copyright © 2020 Atlassian. All rights reserved.