Package com.atlassian.crowd.manager.mail
Class MailManagerImpl
java.lang.Object
com.atlassian.crowd.manager.mail.MailManagerImpl
- All Implemented Interfaces:
MailConfigurationService
,MailManager
-
Field Summary
-
Constructor Summary
ConstructorDescriptionMailManagerImpl
(InternalPropertyManager propertyManager, com.atlassian.sal.api.ApplicationProperties applicationProperties, ClusterService clusterService, Clock clock, I18nHelper i18nHelper, MailSendManager sendManager, AuthenticatedUserProvider authenticatedUserProvider, EmailAddressValidator emailValidator, com.atlassian.event.api.EventPublisher eventPublisher, ClientConfigStorageServiceSupplier clientConfigStorageServiceSupplier) -
Method Summary
Modifier and TypeMethodDescriptionReturns current mail configurationboolean
protected String
removePasswordFromLogs
(String logs) void
saveConfiguration
(MailConfiguration mailConfiguration) Sets the new mail configurationvoid
sendEmail
(EmailMessage messageToSend) Sends a single email using the configured mail serverSet<? 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, javax.activation.DataSource> attachments) Sends an email with zero or more attachments and headers using the configured mail server (remote host / JNDI).sendTestMail
(SMTPServer smtpServer, javax.mail.internet.InternetAddress emailAddress) Send a test email using the supplied mail server (remote host / JNDI)validateConfiguration
(MailConfiguration mailServerEntity) Verifies whether the specified MailConfiguration is valid
-
Field Details
-
SANITISED_PASSWORD
- See Also:
-
LINE_BEFORE_PASSWORD_IN_LOGS
- See Also:
-
-
Constructor Details
-
MailManagerImpl
public MailManagerImpl(InternalPropertyManager propertyManager, com.atlassian.sal.api.ApplicationProperties applicationProperties, ClusterService clusterService, Clock clock, I18nHelper i18nHelper, MailSendManager sendManager, AuthenticatedUserProvider authenticatedUserProvider, EmailAddressValidator emailValidator, com.atlassian.event.api.EventPublisher eventPublisher, ClientConfigStorageServiceSupplier clientConfigStorageServiceSupplier)
-
-
Method Details
-
sendHtmlEmail
public void sendHtmlEmail(javax.mail.internet.InternetAddress emailAddress, String subject, String body, String plainText) throws MailSendException Description copied from interface:MailManager
Sends an HTML email using the configured mail server (remote host / JNDI).- Specified by:
sendHtmlEmail
in interfaceMailManager
- Parameters:
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 inbody
- Throws:
MailSendException
- an error occurred sending the email.
-
sendPlainTextEmail
public void sendPlainTextEmail(javax.mail.internet.InternetAddress emailAddress, String subject, String body) throws MailSendException Description copied from interface:MailManager
Sends an email using the configured mail server (remote host / JNDI).- Specified by:
sendPlainTextEmail
in interfaceMailManager
- Parameters:
emailAddress
- address of recipient.subject
- subject header. Will be appended with the configured mail subject prefix in the final email.body
- email body text.- Throws:
MailSendException
- an error occurred sending the email.
-
sendPlainTextEmail
public void sendPlainTextEmail(javax.mail.internet.InternetAddress emailAddress, String subject, String body, Map<String, String> headers, Map<String, throws MailSendExceptionjavax.activation.DataSource> attachments) Description copied from interface:MailManager
Sends an email with zero or more attachments and headers using the configured mail server (remote host / JNDI).- Specified by:
sendPlainTextEmail
in interfaceMailManager
- Parameters:
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.- Throws:
MailSendException
- an error occurred sending the email.
-
sendTestMail
public SendTestMailResult sendTestMail(SMTPServer smtpServer, javax.mail.internet.InternetAddress emailAddress) throws MailSendException Description copied from interface:MailManager
Send a test email using the supplied mail server (remote host / JNDI)- Specified by:
sendTestMail
in interfaceMailManager
- Parameters:
smtpServer
- supplied SMTP Server, which will be used to send message.emailAddress
- address of recipient.- Returns:
- result of test, which contains logs and status.
- Throws:
MailSendException
- an error occurred sending the email.
-
sendEmails
public Set<? extends EmailMessage> sendEmails(Collection<? extends EmailMessage> messagesToSend) throws MailSendException Description copied from interface:MailManager
Sends multiple emails using the configured mail server.- Specified by:
sendEmails
in interfaceMailManager
- Returns:
- a collection of messages that failed to be sent
- Throws:
MailSendException
- an error occurred that prevented sending any email (connection error, configuration error, etc.).
-
sendEmail
Description copied from interface:MailManager
Sends a single email using the configured mail server- Specified by:
sendEmail
in interfaceMailManager
- Parameters:
messageToSend
- single email using the configured mail server- Throws:
MailSendException
- an error occurred sending the email.
-
validateConfiguration
Description copied from interface:MailManager
Verifies whether the specified MailConfiguration is valid- Specified by:
validateConfiguration
in interfaceMailManager
- Parameters:
mailServerEntity
- entity with attributes to be validated- Returns:
- a list with errors found in the configuration
-
saveConfiguration
Description copied from interface:MailManager
Sets the new mail configuration- Specified by:
saveConfiguration
in interfaceMailConfigurationService
- Specified by:
saveConfiguration
in interfaceMailManager
- Parameters:
mailConfiguration
- new configuration
-
getMailConfiguration
Description copied from interface:MailManager
Returns current mail configuration- Specified by:
getMailConfiguration
in interfaceMailConfigurationService
- Specified by:
getMailConfiguration
in interfaceMailManager
- Returns:
- Mail configuration
-
removePasswordFromLogs
-
isConfigured
public boolean isConfigured()- Specified by:
isConfigured
in interfaceMailConfigurationService
- Specified by:
isConfigured
in interfaceMailManager
- Returns:
true
if the mail server is fully configured (does not check if the configuration is correct)
-