本文整理汇总了Java中org.simplejavamail.mailer.Mailer类的典型用法代码示例。如果您正苦于以下问题:Java Mailer类的具体用法?Java Mailer怎么用?Java Mailer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Mailer类属于org.simplejavamail.mailer包,在下文中一共展示了Mailer类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initMailer
import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
private void initMailer() {
String host = appConfig.get(CONFIG_KEY_SMTP_HOST, "");
int port = appConfig.getInt(CONFIG_KEY_SMTP_PORT, 465);
String secure = appConfig.get(CONFIG_KEY_SMTP_SECURE, "tls");
String username = appConfig.get(CONFIG_KEY_SMTP_USERNAME, "");
String password = appConfig.get(CONFIG_KEY_SMTP_PASS, "");
TransportStrategy transportStrategy = TransportStrategy.SMTP_PLAIN;
if (secure.toLowerCase().equals("tls")) {
transportStrategy = TransportStrategy.SMTP_TLS;
} else if (secure.toLowerCase().equals("ssl")) {
transportStrategy = TransportStrategy.SMTP_SSL;
}
mailer = new Mailer(new ServerConfig(host, port, username, password), transportStrategy);
mailer.setSessionTimeout(30000);
// mailer.setDebug(appConfig.getBool(CONFIG_KEY_APP_DEV_MODE, false));
}
开发者ID:thundernet8,项目名称:Elune,代码行数:22,代码来源:MailMQServiceImpl.java
示例2: main
import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
clearConfigProperties();
final Email emailNormal = new Email();
emailNormal.setFromAddress("lollypop", "[email protected]");
// don't forget to add your own address here ->
emailNormal.addRecipient("C.Cane", YOUR_GMAIL_ADDRESS, RecipientType.TO);
emailNormal.setText("We should meet up!");
emailNormal.setTextHTML("<b>We should meet up!</b><img src='cid:thumbsup'>");
emailNormal.setSubject("hey");
// add two text files in different ways and a black thumbs up embedded image ->
emailNormal.addAttachment("dresscode.txt", new ByteArrayDataSource("Black Tie Optional", "text/plain"));
emailNormal.addAttachment("location.txt", "On the moon!".getBytes(Charset.defaultCharset()), "text/plain");
String base64String = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABeElEQVRYw2NgoAAYGxu3GxkZ7TY1NZVloDcAWq4MxH+B+D8Qv3FwcOCgtwM6oJaDMTAUXOhmuYqKCjvQ0pdoDrCnmwNMTEwakC0H4u8GBgYC9Ap6DSD+iewAoIPm0ctyLqBlp9F8/x+YE4zpYT8T0LL16JYD8U26+B7oyz4sloPwenpYno3DchCeROsUbwa05A8eB3wB4kqgIxOAuArIng7EW4H4EhC/B+JXQLwDaI4ryZaDSjeg5mt4LCcFXyIn1fdSyXJQVt1OtMWGhoai0OD8T0W8GohZifE1PxD/o7LlsPLiFNAKRrwOABWptLAcqc6QGDAHQEOAYaAc8BNotsJAOgAUAosG1AFA/AtUoY3YEFhKMAvS2AE7iC1+WaG1H6gY3gzE36hUFJ8mqzbU1dUVBBqQBzTgIDQRkWo5qCZdpaenJ0Zx1aytrc0DDB0foIG1oAYKqC0IZK8D4n1AfA6IzwPxXpCFoGoZVEUDaRGGUTAKRgEeAAA2eGJC+ETCiAAAAABJRU5ErkJggg==";
emailNormal.addEmbeddedImage("thumbsup", parseBase64Binary(base64String), "image/png");
// let's try producing and then consuming a MimeMessage ->
final MimeMessage mimeMessage = Mailer.produceMimeMessage(emailNormal);
final Email emailFromMimeMessage = new Email(mimeMessage);
// note: the following statements will produce 6 new emails!
sendMail(emailNormal);
sendMail(emailFromMimeMessage); // should produce the exact same result as emailNormal!
}
开发者ID:viydaag,项目名称:dungeonstory-java,代码行数:26,代码来源:MailTestApp.java
示例3: mailConfig
import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
@Bean(name = "mailSender")
public Mailer mailConfig(){
if (mailServerConfig == null) {
synchronized (GenericConfig.class) {
if (mailServerConfig == null) {
mailServerConfig = new ServerConfig(host, port, from, password);
}
}
}
return new Mailer(mailServerConfig);
}
开发者ID:QianWorks,项目名称:qianworks-meican,代码行数:12,代码来源:GenericConfig.java
示例4: initializeMailer
import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
private static Mailer initializeMailer(Config config) {
ConfigLoader.loadProperties(
// Properties are in ISO 8859 1
new ByteArrayInputStream(readMailConfiguration(config).getBytes(StandardCharsets.ISO_8859_1)),
true
);
return new Mailer();
}
开发者ID:Coreoz,项目名称:Plume,代码行数:10,代码来源:MailerProvider.java
示例5: writeReport
import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
/**
* {@inheritDoc}
* <p>
* Render the report HTML using Jtwig and send the result to the recipient emails.
*/
@Override
public void writeReport(List<TestSuite> testSuites) throws IOException {
if (testSuites == null) {
testSuites = Collections.emptyList();
}
log.info("Sending report email for {} test suites", testSuites.size());
List<TestSuiteModel> testList = new ArrayList<>(testSuites.size());
boolean hasError = false;
for (TestSuite testSuite : testSuites) {
TestSuiteModel testSuiteModel = new TestSuiteModel(testSuite);
hasError = hasError || !testSuiteModel.allPassed();
testList.add(testSuiteModel);
}
JtwigTemplate template = JtwigTemplate.classpathTemplate("templates/email.twig");
JtwigModel model = JtwigModel.newModel()
.with("error", hasError)
.with("testList", testList);
String reportHtml = template.render(model);
EmailBuilder emailBuilder = new EmailBuilder().from(senderName, fromEmail)
.replyTo(senderName, replyTo)
.subject("Validatar Report – " + (hasError ? "Test Errors" : "Tests Passed"))
.addHeader("X-Priority", 2)
.textHTML(reportHtml);
for (String recipientEmail : recipientEmails) {
emailBuilder.to(recipientEmail);
}
Email reportEmail = emailBuilder.build();
ServerConfig mailServerConfig = new ServerConfig(smtpHost, smtpPort);
Mailer reportMailer = new Mailer(mailServerConfig, TransportStrategy.SMTP_TLS);
sendEmail(reportMailer, reportEmail);
log.info("Finished sending report to recipients");
}
开发者ID:yahoo,项目名称:validatar,代码行数:38,代码来源:EmailFormatter.java
示例6: testSendEmail
import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
@Test
public void testSendEmail() {
Mailer mailer = mock(Mailer.class);
Email email = mock(Email.class);
EmailFormatter formatter = new EmailFormatter();
formatter.sendEmail(mailer, email);
verify(mailer).sendMail(email);
}
开发者ID:yahoo,项目名称:validatar,代码行数:9,代码来源:EmailFormatterTest.java
示例7: buildMailer
import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
private static final Mailer buildMailer(String host, int port, String gMailAddress, String gMailPassword, TransportStrategy strategy) {
return MailerBuilder
.withSMTPServer(host, port, gMailAddress, gMailPassword)
.withTransportStrategy(strategy)
.withTransportModeLoggingOnly(LOGGING_MODE)
.buildMailer();
}
开发者ID:bbottema,项目名称:simple-java-mail,代码行数:8,代码来源:MailTestDemoApp.java
示例8: start
import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
public void start() {
mailer = new Mailer(
new ServerConfig(
Configuration.i.getSmtp().getHost(),
Configuration.i.getSmtp().getPort(),
Configuration.i.getSmtp().getUserName(),
Configuration.i.getSmtp().getPassword()),
TransportStrategy.SMTP_TLS);
Properties props = new Properties();
props.put("mail.smtp.localhost", "codeka.com.au");
mailer.applyProperties(props);
}
开发者ID:codeka,项目名称:wwmmo,代码行数:14,代码来源:SmtpHelper.java
示例9: sendMail
import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
@Override
public void sendMail() {
new Mailer( new ServerConfig("smtp.host.com", 587),
TransportStrategy.SMTP_TLS
).sendMail(email);
}
开发者ID:maugern,项目名称:jersey-skeleton,代码行数:7,代码来源:ConfirmationMail.java
示例10: sendMail
import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
@Override
public void sendMail() {
new Mailer(new ServerConfig("smtp.host.com", 587), TransportStrategy.SMTP_TLS).sendMail(email);
}
开发者ID:maugern,项目名称:jersey-skeleton,代码行数:5,代码来源:NewPasswordMail.java
示例11: MailService
import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
private MailService() {
mailer = new Mailer(Config.getCatalog().mail.server, Config.getCatalog().mail.port, Config.getCatalog().mail.user, Config.getCatalog().mail.password, TransportStrategy.SMTP_TLS);
mailer.setDebug(false);
mailer.trustAllSSLHosts(true);
}
开发者ID:Twasi,项目名称:twasi-core,代码行数:6,代码来源:MailService.java
示例12: getMailer
import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
public Mailer getMailer() {
return mailer;
}
开发者ID:Twasi,项目名称:twasi-core,代码行数:4,代码来源:MailService.java
示例13: MailServerHealthCheck
import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
public MailServerHealthCheck(final Mailer mailer) {
this.mailer = mailer;
}
开发者ID:msteinhoff,项目名称:dropwizard-smtp-mail,代码行数:4,代码来源:MailServerHealthCheck.java
示例14: sendMail
import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
private static void sendMail(final Email email) {
ProxyConfig proxyconfig = new ProxyConfig("", 8080, "", "");
new Mailer(serverConfigSMTP, TransportStrategy.SMTP_TLS, proxyconfig).sendMail(email);
new Mailer(serverConfigTLS, TransportStrategy.SMTP_TLS, proxyconfig).sendMail(email);
new Mailer(serverConfigSSL, TransportStrategy.SMTP_SSL).sendMail(email);
}
开发者ID:viydaag,项目名称:dungeonstory-java,代码行数:7,代码来源:MailTestApp.java
示例15: configure
import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
@Override
protected void configure() {
bind(Mailer.class).toProvider(MailerProvider.class);
}
开发者ID:Coreoz,项目名称:Plume,代码行数:5,代码来源:GuiceMailModule.java
示例16: provideMailer
import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
@Provides
@Singleton
static Mailer provideMailer(MailerProvider mailerProvider) {
return mailerProvider.get();
}
开发者ID:Coreoz,项目名称:Plume,代码行数:6,代码来源:DaggerMailModule.java
示例17: get
import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
@Override
public Mailer get() {
return mailer;
}
开发者ID:Coreoz,项目名称:Plume,代码行数:5,代码来源:MailerProvider.java
示例18: loadGlobalConfigAndCreateDefaultMailer
import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
@Bean
public Mailer loadGlobalConfigAndCreateDefaultMailer(
// now obviously there are easier ways to do this, but this is the only way
// I can think of that actually works across Spring versions
@Value("${simplejavamail.javaxmail.debug:#{null}}") final String javaxmailDebug,
@Value("${simplejavamail.transportstrategy:#{null}}") final String transportstrategy,
@Value("${simplejavamail.smtp.host:#{null}}") final String smtpHost,
@Value("${simplejavamail.smtp.port:#{null}}") final String smtpPort,
@Value("${simplejavamail.smtp.username:#{null}}") final String smtpUsername,
@Value("${simplejavamail.smtp.password:#{null}}") final String smtpPassword,
@Value("${simplejavamail.proxy.host:#{null}}") final String proxyHost,
@Value("${simplejavamail.proxy.port:#{null}}") final String proxyPort,
@Value("${simplejavamail.proxy.username:#{null}}") final String proxyUsername,
@Value("${simplejavamail.proxy.password:#{null}}") final String proxyPassword,
@Value("${simplejavamail.proxy.socks5bridge.port:#{null}}") final String proxySocks5bridgePort,
@Value("${simplejavamail.defaults.subject:#{null}}") final String defaultSubject,
@Value("${simplejavamail.defaults.from.name:#{null}}") final String defaultFromName,
@Value("${simplejavamail.defaults.from.address:#{null}}") final String defaultFromAddress,
@Value("${simplejavamail.defaults.replyto.name:#{null}}") final String defaultReplytoName,
@Value("${simplejavamail.defaults.replyto.address:#{null}}") final String defaultReplytoAddress,
@Value("${simplejavamail.defaults.bounceto.name:#{null}}") final String defaultBouncetoName,
@Value("${simplejavamail.defaults.bounceto.address:#{null}}") final String defaultBouncetoAddress,
@Value("${simplejavamail.defaults.to.name:#{null}}") final String defaultToName,
@Value("${simplejavamail.defaults.to.address:#{null}}") final String defaultToAddress,
@Value("${simplejavamail.defaults.cc.name:#{null}}") final String defaultCcName,
@Value("${simplejavamail.defaults.cc.address:#{null}}") final String defaultCcAddress,
@Value("${simplejavamail.defaults.bcc.name:#{null}}") final String defaultBccName,
@Value("${simplejavamail.defaults.bcc.address:#{null}}") final String defaultBccAddress,
@Value("${simplejavamail.defaults.poolsize:#{null}}") final String defaultPoolsize,
@Value("${simplejavamail.defaults.sessiontimeoutmillis:#{null}}") final String defaultSessionTimeoutMillis,
@Value("${simplejavamail.transport.mode.logging.only:#{null}}") final String defaultTransportModeLoggingOnly,
@Value("${simplejavamail.opportunistic.tls:#{null}}") final String defaultOpportunisticTls) {
final Properties emailProperties = new Properties();
setNullableProperty(emailProperties, Property.JAVAXMAIL_DEBUG.key(), javaxmailDebug);
setNullableProperty(emailProperties, Property.TRANSPORT_STRATEGY.key(), transportstrategy);
setNullableProperty(emailProperties, Property.SMTP_HOST.key(), smtpHost);
setNullableProperty(emailProperties, Property.SMTP_PORT.key(), smtpPort);
setNullableProperty(emailProperties, Property.SMTP_USERNAME.key(), smtpUsername);
setNullableProperty(emailProperties, Property.SMTP_PASSWORD.key(), smtpPassword);
setNullableProperty(emailProperties, Property.PROXY_HOST.key(), proxyHost);
setNullableProperty(emailProperties, Property.PROXY_PORT.key(), proxyPort);
setNullableProperty(emailProperties, Property.PROXY_USERNAME.key(), proxyUsername);
setNullableProperty(emailProperties, Property.PROXY_PASSWORD.key(), proxyPassword);
setNullableProperty(emailProperties, Property.PROXY_SOCKS5BRIDGE_PORT.key(), proxySocks5bridgePort);
setNullableProperty(emailProperties, Property.DEFAULT_SUBJECT.key(), defaultSubject);
setNullableProperty(emailProperties, Property.DEFAULT_FROM_NAME.key(), defaultFromName);
setNullableProperty(emailProperties, Property.DEFAULT_FROM_ADDRESS.key(), defaultFromAddress);
setNullableProperty(emailProperties, Property.DEFAULT_REPLYTO_NAME.key(), defaultReplytoName);
setNullableProperty(emailProperties, Property.DEFAULT_REPLYTO_ADDRESS.key(), defaultReplytoAddress);
setNullableProperty(emailProperties, Property.DEFAULT_BOUNCETO_NAME.key(), defaultBouncetoName);
setNullableProperty(emailProperties, Property.DEFAULT_BOUNCETO_ADDRESS.key(), defaultBouncetoAddress);
setNullableProperty(emailProperties, Property.DEFAULT_TO_NAME.key(), defaultToName);
setNullableProperty(emailProperties, Property.DEFAULT_TO_ADDRESS.key(), defaultToAddress);
setNullableProperty(emailProperties, Property.DEFAULT_CC_NAME.key(), defaultCcName);
setNullableProperty(emailProperties, Property.DEFAULT_CC_ADDRESS.key(), defaultCcAddress);
setNullableProperty(emailProperties, Property.DEFAULT_BCC_NAME.key(), defaultBccName);
setNullableProperty(emailProperties, Property.DEFAULT_BCC_ADDRESS.key(), defaultBccAddress);
setNullableProperty(emailProperties, Property.DEFAULT_POOL_SIZE.key(), defaultPoolsize);
setNullableProperty(emailProperties, Property.DEFAULT_SESSION_TIMEOUT_MILLIS.key(), defaultSessionTimeoutMillis);
setNullableProperty(emailProperties, Property.TRANSPORT_MODE_LOGGING_ONLY.key(), defaultTransportModeLoggingOnly);
setNullableProperty(emailProperties, Property.OPPORTUNISTIC_TLS.key(), defaultOpportunisticTls);
ConfigLoader.loadProperties(emailProperties, true);
// this will configure itself with the global config and is read to use
// ofcourse this is optional simply as a convenience default
return MailerBuilder.buildMailer();
}
开发者ID:bbottema,项目名称:simple-java-mail,代码行数:69,代码来源:SimpleJavaMailSpringSupport.java
示例19: sendEmail
import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
/**
* Method uses the provided mailer to send the email report.
*
* @param mailer mailer to use
* @param email report email
*/
protected void sendEmail(Mailer mailer, Email email) {
mailer.sendMail(email);
}
开发者ID:yahoo,项目名称:validatar,代码行数:10,代码来源:EmailFormatter.java
注:本文中的org.simplejavamail.mailer.Mailer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论