Package org.apache.commons.mail
Class ImageHtmlEmail
- java.lang.Object
-
- org.apache.commons.mail.Email
-
- org.apache.commons.mail.MultiPartEmail
-
- org.apache.commons.mail.HtmlEmail
-
- org.apache.commons.mail.ImageHtmlEmail
-
public class ImageHtmlEmail extends HtmlEmail
Small wrapper class on top of HtmlEmail which encapsulates the required logic to retrieve images that are contained in "<img src=../>" elements in the HTML code. This is done by replacing all img-src-elements with "cid:"-entries and embedding images in the email.
For local files the class tries to either load them via an absolute path or - if available - use a relative path starting from a base directory. For files that are not found locally, the implementation tries to download the element and link it in.
The image loading is done by an instance of
DataSourceResolverwhich has to be provided by the caller.- Since:
- 1.3
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringREGEX_IMG_SRCRegexp for extracting<img>tagsstatic java.lang.StringREGEX_SCRIPT_SRCregexp for extracting<script>tags-
Fields inherited from class org.apache.commons.mail.HtmlEmail
CID_LENGTH
-
Fields inherited from class org.apache.commons.mail.Email
ATTACHMENTS, CONTENT_TYPE, EMAIL_BODY, EMAIL_SUBJECT, FILE_SERVER, ISO_8859_1, KOI8_R, MAIL_DEBUG, MAIL_HOST, MAIL_PORT, MAIL_SMTP_AUTH, MAIL_SMTP_CONNECTIONTIMEOUT, MAIL_SMTP_FROM, MAIL_SMTP_PASSWORD, MAIL_SMTP_SOCKET_FACTORY_CLASS, MAIL_SMTP_SOCKET_FACTORY_FALLBACK, MAIL_SMTP_SOCKET_FACTORY_PORT, MAIL_SMTP_TIMEOUT, MAIL_SMTP_USER, MAIL_TRANSPORT_PROTOCOL, MAIL_TRANSPORT_TLS, RECEIVER_EMAIL, RECEIVER_NAME, SENDER_EMAIL, SENDER_NAME, SMTP, TEXT_HTML, TEXT_PLAIN, US_ASCII
-
-
Constructor Summary
Constructors Constructor Description ImageHtmlEmail()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbuildMimeMessage()Does the work of actually building the MimeMessage.DataSourceResolvergetDataSourceResolver()Get the data source resolver.voidsetDataSourceResolver(DataSourceResolver dataSourceResolver)Set the data source resolver.-
Methods inherited from class org.apache.commons.mail.HtmlEmail
embed, embed, embed, embed, embed, embed, setHtmlMsg, setMsg, setTextMsg
-
Methods inherited from class org.apache.commons.mail.MultiPartEmail
addPart, addPart, addPart, attach, attach, attach, attach, attach, attach, getSubType, isBoolHasAttachments, setBoolHasAttachments, setSubType
-
Methods inherited from class org.apache.commons.mail.Email
addBcc, addBcc, addBcc, addBcc, addCc, addCc, addCc, addCc, addHeader, addReplyTo, addReplyTo, addReplyTo, addTo, addTo, addTo, addTo, getBccAddresses, getBounceAddress, getCcAddresses, getFromAddress, getHeader, getHeaders, getHostName, getMailSession, getMimeMessage, getReplyToAddresses, getSentDate, getSmtpPort, getSocketConnectionTimeout, getSocketTimeout, getSslSmtpPort, getSubject, getToAddresses, isSendPartial, isSSL, isSSLCheckServerIdentity, isSSLOnConnect, isStartTLSEnabled, isStartTLSRequired, isTLS, send, sendMimeMessage, setAuthentication, setAuthenticator, setBcc, setBounceAddress, setCc, setCharset, setContent, setContent, setDebug, setFrom, setFrom, setFrom, setHeaders, setHostName, setMailSession, setMailSessionFromJNDI, setPopBeforeSmtp, setReplyTo, setSendPartial, setSentDate, setSmtpPort, setSocketConnectionTimeout, setSocketTimeout, setSSL, setSSLCheckServerIdentity, setSSLOnConnect, setSslSmtpPort, setStartTLSEnabled, setStartTLSRequired, setSubject, setTLS, setTo, updateContentType
-
-
-
-
Field Detail
-
REGEX_IMG_SRC
public static final java.lang.String REGEX_IMG_SRC
Regexp for extracting<img>tags- See Also:
- Constant Field Values
-
REGEX_SCRIPT_SRC
public static final java.lang.String REGEX_SCRIPT_SRC
regexp for extracting<script>tags- See Also:
- Constant Field Values
-
-
Method Detail
-
getDataSourceResolver
public DataSourceResolver getDataSourceResolver()
Get the data source resolver.- Returns:
- the resolver
-
setDataSourceResolver
public void setDataSourceResolver(DataSourceResolver dataSourceResolver)
Set the data source resolver.- Parameters:
dataSourceResolver- the resolver
-
buildMimeMessage
public void buildMimeMessage() throws EmailExceptionDoes the work of actually building the MimeMessage.- Overrides:
buildMimeMessagein classHtmlEmail- Throws:
EmailException- building the MimeMessage failed- See Also:
HtmlEmail.buildMimeMessage()
-
-