Java 类javax.mail.Provider 实例源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
文件:MailHealthIndicatorTests.java
@Before
public void setup() {
Session session = Session.getDefaultInstance(new Properties());
session.addProvider(new Provider(Type.TRANSPORT, "success",
SuccessTransport.class.getName(), "Test", "1.0.0"));
this.mailSender = mock(JavaMailSenderImpl.class);
given(this.mailSender.getHost()).willReturn("smtp.acme.org");
given(this.mailSender.getPort()).willReturn(25);
given(this.mailSender.getSession()).willReturn(session);
this.indicator = new MailHealthIndicator(this.mailSender);
}
项目:spring-boot-concourse
文件:MailHealthIndicatorTests.java
@Before
public void setup() {
Session session = Session.getDefaultInstance(new Properties());
session.addProvider(new Provider(Type.TRANSPORT, "success",
SuccessTransport.class.getName(), "Test", "1.0.0"));
this.mailSender = mock(JavaMailSenderImpl.class);
given(this.mailSender.getHost()).willReturn("smtp.acme.org");
given(this.mailSender.getPort()).willReturn(25);
given(this.mailSender.getSession()).willReturn(session);
this.indicator = new MailHealthIndicator(this.mailSender);
}
项目:smtp-connection-pool
文件:TransportStrategyFactory.java
public static TransportStrategy newProviderStrategy(final Provider provider) {
return new TransportStrategy() {
@Override
public Transport getTransport(Session session) throws NoSuchProviderException {
return session.getTransport(provider);
}
};
}
项目:contestparser
文件:MailHealthIndicatorTests.java
@Before
public void setup() {
Session session = Session.getDefaultInstance(new Properties());
session.addProvider(new Provider(Type.TRANSPORT, "success",
SuccessTransport.class.getName(), "Test", "1.0.0"));
this.mailSender = mock(JavaMailSenderImpl.class);
given(this.mailSender.getHost()).willReturn("smtp.acme.org");
given(this.mailSender.getPort()).willReturn(25);
given(this.mailSender.getSession()).willReturn(session);
this.indicator = new MailHealthIndicator(this.mailSender);
}
项目:FlexibleLogin
文件:ForgotPasswordCommand.java
private Session buildSession(EmailConfiguration emailConfig) {
Properties properties = new Properties();
properties.setProperty("mail.smtp.host", emailConfig.getHost());
properties.setProperty("mail.smtp.auth", "true");
properties.setProperty("mail.smtp.port", String.valueOf(emailConfig.getPort()));
//ssl
properties.setProperty("mail.smtp.socketFactory.port", String.valueOf(emailConfig.getPort()));
properties.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
properties.setProperty("mail.smtp.socketFactory.fallback", "false");
properties.setProperty("mail.smtp.starttls.enable", String.valueOf(true));
properties.setProperty("mail.smtp.ssl.checkserveridentity", "true");
properties.setProperty("mail.transport.protocol", "flexiblelogin");
Session session = Session.getDefaultInstance(properties);
//explicit override stmp provider because of issues with relocation
try {
session.setProvider(new Provider(Type.TRANSPORT, "smtps",
"flexiblelogin.sun.mail.smtp.SMTPSSLTransport", "Oracle", "1.6.0"));
session.setProvider(new Provider(Type.TRANSPORT, "flexiblelogin",
"flexiblelogin.sun.mail.smtp.SMTPSSLTransport", "Oracle", "1.6.0"));
} catch (NoSuchProviderException noSuchProvider) {
logger.error("Failed to add STMP provider", noSuchProvider);
}
return session;
}
项目:javamail-mock2
文件:Providers.java
public static Provider getIMAPProvider(final String protocol, final boolean secure, final boolean mock) {
if (mock) {
return new Provider(Provider.Type.STORE, protocol, secure ? "de.saly.javamail.mock2.IMAPSSLMockStore"
: "de.saly.javamail.mock2.IMAPMockStore", "JavaMail Mock2 provider", null);
}
return new Provider(Provider.Type.STORE, protocol, secure ? "com.sun.mail.imap.IMAPSSLStore" : "com.sun.mail.imap.IMAPStore",
"Oracle", null);
}
项目:javamail-mock2
文件:Providers.java
public static Provider getPOP3Provider(final String protocol, final boolean secure, final boolean mock) {
if (mock) {
return new Provider(Provider.Type.STORE, protocol, secure ? "de.saly.javamail.mock2.POP3SSLMockStore"
: "de.saly.javamail.mock2.POP3MockStore", "JavaMail Mock2 provider", null);
}
return new Provider(Provider.Type.STORE, protocol, secure ? "com.sun.mail.pop3.POP3SSLStore" : "com.sun.mail.pop3.POP3Store",
"Oracle", null);
}
项目:javamail-mock2
文件:Providers.java
public static Provider getSMTPProvider(final String protocol, final boolean secure, final boolean mock) {
if (mock) {
return new Provider(Provider.Type.TRANSPORT, protocol, "de.saly.javamail.mock2.MockTransport", "JavaMail Mock2 provider", null);
}
return new Provider(Provider.Type.TRANSPORT, protocol, secure ? "com.sun.mail.smtp.SMTPSSLTransport"
: "com.sun.mail.smtp.SMTPTransport", "Oracle", null);
}