@Override public MimeMessage createMimeMessage(InputStream contentStream) throws MailException { try { return new MimeMessage(getSession(), contentStream); } catch (Exception ex) { throw new MailParseException("Could not parse raw MIME content", ex); } }
@Override public MimeMessage createMimeMessage(InputStream contentStream) throws MailException { try { return new MimeMessage(getSession(), contentStream); } catch (Exception ex) { throw new MailParseException("Could not parse raw MIME content", ex); } }
/** * This implementation creates a SmartMimeMessage, holding the specified * default encoding and default FileTypeMap. This special defaults-carrying * message will be autodetected by {@link MimeMessageHelper}, which will use * the carried encoding and FileTypeMap unless explicitly overridden. * @see #setDefaultEncoding * @see #setDefaultFileTypeMap */ @Override public MimeMessage createMimeMessage() { return new SmartMimeMessage(getSession(), getDefaultEncoding(), getDefaultFileTypeMap()); }
/** * Obtain and connect a Transport from the underlying JavaMail Session, * passing in the specified host, port, username, and password. * @return the connected Transport object * @throws MessagingException if the connect attempt failed * @since 4.1.2 * @see #getTransport * @see #getHost() * @see #getPort() * @see #getUsername() * @see #getPassword() */ protected Transport connectTransport() throws MessagingException { String username = getUsername(); String password = getPassword(); if ("".equals(username)) { // probably from a placeholder username = null; if ("".equals(password)) { // in conjunction with "" username, this means no password to use password = null; } } Transport transport = getTransport(getSession()); transport.connect(getHost(), getPort(), username, password); return transport; }
/** * This implementation creates a SmartMimeMessage, holding the specified * default encoding and default FileTypeMap. This special defaults-carrying * message will be autodetected by {@link MimeMessageHelper}, which will use * the carried encoding and FileTypeMap unless explicitly overridden. * @see #setDefaultEncoding * @see #setDefaultFileTypeMap */ @Override public MimeMessage createMimeMessage() { return new SmartMimeMessage(getSession(), getDefaultEncoding(), getDefaultFileTypeMap()); }
/** * Obtain and connect a Transport from the underlying JavaMail Session, * passing in the specified host, port, username, and password. * @return the connected Transport object * @throws MessagingException if the connect attempt failed * @since 4.1.2 * @see #getTransport * @see #getHost() * @see #getPort() * @see #getUsername() * @see #getPassword() */ protected Transport connectTransport() throws MessagingException { String username = getUsername(); String password = getPassword(); if ("".equals(username)) { // probably from a placeholder username = null; if ("".equals(password)) { // in conjunction with "" username, this means no password to use password = null; } } Transport transport = getTransport(getSession()); transport.connect(getHost(), getPort(), username, password); return transport; }
/** * Enable debugging and return the stream * @return */ public void setDebug(PrintStream stream) { senderImpl.getSession().setDebug(true); senderImpl.getSession().setDebugOut(stream); }
@Override public synchronized Session getSession() { if (!propertiesInitialized) { Properties properties = createJavaMailProperties(); setJavaMailProperties(properties); propertiesInitialized = true; } return super.getSession(); }
@Override public void afterPropertiesSet() throws Exception { if (mailSender instanceof JavaMailSenderImpl) { JavaMailSenderImpl javaMailSender = (JavaMailSenderImpl) mailSender; Properties javaMailProperties = javaMailSender.getJavaMailProperties(); Properties props = PropertyUtils.read(Encryptor.class, "mail.properties", "conf.directory").getLeft(); for (Enumeration<?> e = props.propertyNames(); e.hasMoreElements();) { String prop = (String) e.nextElement(); if (prop.startsWith("mail.smtp.")) { javaMailProperties.setProperty(prop, props.getProperty(prop)); } } if (StringUtils.isNotBlank(javaMailSender.getUsername())) { javaMailProperties.setProperty("mail.smtp.auth", "true"); } javaMailSender.setJavaMailProperties(javaMailProperties); String mailDebug = props.getProperty("mail.debug", "false"); if (BooleanUtils.toBoolean(mailDebug)) { Session session = javaMailSender.getSession(); session.setDebug(true); session.setDebugOut(new PrintStream(new LogOutputStream(LOG))); } } }
Session session = javaMailSender.getSession(); String protocol = javaMailSender.getProtocol(); if (protocol == null) {
public MimeMessage createMimeMessage(InputStream contentStream) throws MailException { try { return new MimeMessage(getSession(), contentStream);