public class BasicMailService extends Object implements MailService
<bean id="sharedMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="localhost"/>
<property name="defaultEncoding" value="UTF-8"/>
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.connectiontimeout">30000</prop>
<prop key="mail.smtp.timeout">30000</prop>
</props>
</property>
</bean>
<bean id="mailService" class="com.foreach.spring.mail.BasicMailService">
<property name="originator" value="noreply@foo.bar"/>
<property name="executorService">
<bean class="java.util.concurrent.ScheduledThreadPoolExecutor" destroy-method="shutdown">
<constructor-arg index="0" type="int" value="2"/>
</bean>
</property>
<property name="javaMailSender" ref="sharedMailSender"/>
</bean>
| Constructor and Description |
|---|
BasicMailService() |
| Modifier and Type | Method and Description |
|---|---|
ExecutorService |
getExecutorService()
Get the current ExecutorService being used.
|
protected org.slf4j.Logger |
getLogger()
Get the logger
|
String |
getServiceBccRecipients() |
Future<MailStatus> |
sendMimeMail(String from,
String to,
String bccs,
String subject,
String body,
Map<String,File> attachments)
Send a mail message with optional attachments.
|
void |
setExecutorService(ExecutorService executorService)
Set the executorService used to send messages through the javaMailSender.
|
void |
setJavaMailSender(org.springframework.mail.javamail.JavaMailSender javaMailSender)
Set the JavaMailSender to be used.
|
protected void |
setLogger(org.slf4j.Logger logger) |
void |
setOriginator(String originator)
Set the default originator to be used to send messages through the javaMailSender.
|
void |
setServiceBccRecipients(String serviceBccRecipients)
Set the default bcc: recipients for this service.
|
protected final void setLogger(org.slf4j.Logger logger)
protected final org.slf4j.Logger getLogger()
public final void setJavaMailSender(org.springframework.mail.javamail.JavaMailSender javaMailSender)
public final void setOriginator(String originator)
originator - the email address of the default originator.
This value can be overridden on a per message basis.public final void setServiceBccRecipients(String serviceBccRecipients)
serviceBccRecipients - a comma or semicolon separated list of email adresses.
This value can be overridden on a per message basis.public final String getServiceBccRecipients()
public final void setExecutorService(ExecutorService executorService)
executorService - By default, a synchronous TaskExecutoService is configured.public final ExecutorService getExecutorService()
public final Future<MailStatus> sendMimeMail(String from, String to, String bccs, String subject, String body, Map<String,File> attachments)
sendMimeMail in interface MailServicefrom - the email address of the originator.to - the email address(es) of the intended recipient(s).bccs - the email address(es) of other intended recipient(s).subject - the subject of the mail message.body - the body of the mail message.attachments - a map of included files.Copyright © 2017. All rights reserved.