当前位置: 首页>>代码示例>>Java>>正文


Java Email.setSmtpPort方法代码示例

本文整理汇总了Java中org.apache.commons.mail.Email.setSmtpPort方法的典型用法代码示例。如果您正苦于以下问题:Java Email.setSmtpPort方法的具体用法?Java Email.setSmtpPort怎么用?Java Email.setSmtpPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.mail.Email的用法示例。


在下文中一共展示了Email.setSmtpPort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendEmail

import org.apache.commons.mail.Email; //导入方法依赖的package包/类
public void sendEmail(final EmailData emailData) {
  try {
    Email email = new SimpleEmail();
    email.setHostName(smtpServer);
    email.setSmtpPort(smtpPort);
    email.setAuthenticator(new DefaultAuthenticator(username, password));
    email.setSSLOnConnect(secure);
    email.setFrom(emailData.getAddressFrom());
    email.setSubject(emailData.getSubject());
    email.setMsg(emailData.getMessageContent());
    email.addTo(emailData.getAddressTo());
    email.send();
  } catch (org.apache.commons.mail.EmailException e) {
    throw new EmailException(e);
  }
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:17,代码来源:EmailSender.java

示例2: configureConnection

import org.apache.commons.mail.Email; //导入方法依赖的package包/类
private static void configureConnection(Email email) {
	try {
		email.setSmtpPort(SMTP_PORT);
		email.setHostName(SMTP_HOST);
		email.setCharset(CHARSET);
		if (!GeneralUtils.isEmpty(SMTP_USER)) {
			email.setAuthentication(
				SMTP_USER,
				SMTP_PASSWORD
			);
		}
		email.setSSLOnConnect(SMTP_SSL);
		email.setStartTLSEnabled(SMTP_TLS);
	} catch (Throwable ex) {
		LOG.error("Erro ao configurar o email.", ex);
		throw new RuntimeException("Error configuring smtp connection.", ex);
	}
}
 
开发者ID:progolden,项目名称:vraptor-boilerplate,代码行数:19,代码来源:EmailUtils.java

示例3: send

import org.apache.commons.mail.Email; //导入方法依赖的package包/类
protected void send(String mailAddress, String title, String content) {
    if (StringUtils.isBlank(mailAddress)) {
        return;
    }

    try {
        Email email = new HtmlEmail();
        email.setHostName(hostname);
        email.setAuthenticator(new DefaultAuthenticator(username, password));
        email.setSmtpPort(port);
        email.setFrom(from, fromname);
        email.setSubject(title);
        email.setMsg(content);
        email.addTo(mailAddress.split(mailAddressEndSeparator));
        email.send();
    } catch (Exception e) {
        logger.error("Send Mail Error", e);
    }
}
 
开发者ID:XiaoMi,项目名称:shepher,代码行数:20,代码来源:GeneralMailSender.java

示例4: send

import org.apache.commons.mail.Email; //导入方法依赖的package包/类
@Override
public void send(String absender, String empfaenger, String betreff, String text) {
	try {
		final Email email = new SimpleEmail();
		email.setHostName(mailhost);
		email.setSmtpPort(mailport);
		email.setFrom(absender);
		email.setSubject(betreff);
		email.setMsg(text);
		email.addTo(empfaenger);
		email.send();
		log.info("mail sent to: " + empfaenger);
	} catch (final EmailException e) {
		log.error(e.getMessage(), e);
	}
}
 
开发者ID:SchweizerischeBundesbahnen,项目名称:releasetrain,代码行数:17,代码来源:SMTPUtilImpl.java

示例5: createEmail

import org.apache.commons.mail.Email; //导入方法依赖的package包/类
protected Email createEmail() {
    Email email = new SimpleEmail();
    email.setHostName(config.readString(ConfigProperty.SMTP_HOST_NAME));
    email.setSSLOnConnect(config.readBoolean(ConfigProperty.SMTP_USE_SSL));
    if (config.readBoolean(ConfigProperty.SMTP_USE_SSL)) {
        email.setSslSmtpPort(config.readString(ConfigProperty.SMTP_PORT));
    } else {
        email.setSmtpPort(config.readInt(ConfigProperty.SMTP_PORT));
    }
    if (config.readBoolean(ConfigProperty.SMTP_AUTH)) {
        email.setAuthenticator(new DefaultAuthenticator(config.readString(ConfigProperty.SMTP_DEFAULT_USERNAME),
                config.readString(ConfigProperty.SMTP_DEFAULT_PASSWORD)));
    }
    try {
        email.setFrom(config.readString(ConfigProperty.EMAIL_DEFAULT_FROM),
                config.readString(ConfigProperty.EMAIL_DEFAULT_FROM_NAME));
    } catch (EmailException e) {
        throw Exceptions.runtime(e);
    }
    email.setSocketConnectionTimeout(config.readInt(ConfigProperty.SMTP_CONNECTION_TIMEOUT));
    email.setSocketTimeout(config.readInt(ConfigProperty.SMTP_SEND_TIMEOUT));
    return email;
}
 
开发者ID:dmart28,项目名称:gcplot,代码行数:24,代码来源:SMTPMailProvider.java

示例6: sendMail

import org.apache.commons.mail.Email; //导入方法依赖的package包/类
private static void sendMail(String title, String message, String emailaddy) {
    try {
        Email email = new SimpleEmail();
        email.setHostName(p.getProperty("mailserver.host"));
        email.setSmtpPort(Integer.parseInt(p.getProperty("mailserver.port")));
        if(p.getProperty("mailserver.useauth").equals("true"))
        {
            email.setAuthentication(p.getProperty("mailserver.user"), p.getProperty("mailserver.pass"));
        }
        if(p.getProperty("mailserver.usessl").equals("true"))
        {
            email.setSSLOnConnect(true);
        }
        else
        {
            email.setSSLOnConnect(false);
        }
        email.setFrom(p.getProperty("mailserver.from"));
        email.setSubject("[MuninMX] " + title);
        email.setMsg(message);
        email.addTo(emailaddy);
        email.send();
    } catch (Exception ex) {
        logger.warn("Unable to send Mail: " + ex.getLocalizedMessage());
    }
}
 
开发者ID:flyersa,项目名称:MuninMX,代码行数:27,代码来源:Methods.java

示例7: setMailServerProperties

import org.apache.commons.mail.Email; //导入方法依赖的package包/类
protected void setMailServerProperties(Email email) {
  ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();

  String host = processEngineConfiguration.getMailServerHost();
  if (host == null) {
    throw new ActivitiException("Could not send email: no SMTP host is configured");
  }
  email.setHostName(host);

  int port = processEngineConfiguration.getMailServerPort();
  email.setSmtpPort(port);

  String user = processEngineConfiguration.getMailServerUsername();
  String password = processEngineConfiguration.getMailServerPassword();
  if (user != null && password != null) {
    email.setAuthentication(user, password);
  }
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:19,代码来源:MailActivityBehavior.java

示例8: send

import org.apache.commons.mail.Email; //导入方法依赖的package包/类
@RequestMapping("/send")
public HttpEntity<Void> send() throws EmailException {

  // An unlucky fool hardcoded some smtp code here.
  Email email = new SimpleEmail();
  email.setHostName("localhost");
  email.setSmtpPort(3025);
  email.setAuthenticator(new DefaultAuthenticator("username", "password"));
  email.setFrom("[email protected]");
  email.setSubject("TestMail");
  email.setMsg("This is a test mail ... :-)");
  email.addTo("[email protected]");
  email.send();

  return ResponseEntity.ok().build();
}
 
开发者ID:AndreasKl,项目名称:java-classic-playground,代码行数:17,代码来源:SendMailController.java

示例9: applySendSettings

import org.apache.commons.mail.Email; //导入方法依赖的package包/类
/**
 * Applies {@link SmtpClientConfig} options to the {@link Email} being sent.
 *
 * @param email
 *            Email to be sent.
 * @param settings
 *            Send settings to apply to the email
 */
private void applySendSettings(Email email, SmtpClientConfig settings) {
    email.setHostName(settings.getSmtpHost());
    email.setSmtpPort(settings.getSmtpPort());
    email.setSslSmtpPort(String.valueOf(settings.getSmtpPort()));
    if (settings.getAuthentication() != null) {
        email.setAuthentication(settings.getAuthentication().getUsername(),
                settings.getAuthentication().getPassword());
    }
    if (settings.isUseSsl()) {
        // enable the use of SSL for SMTP connections. NOTE: should
        // only be used for cases when the SMTP server port only supports
        // SSL connections (typically over port 465).
        email.setSSLOnConnect(true);
    } else {
        // Support use of the STARTTLS command (see RFC 2487 and RFC 3501)
        // to switch the connection to be secured by TLS for cases where the
        // server supports both SSL and non-SSL connections. This is
        // typically the case for most modern mail servers.
        email.setStartTLSEnabled(true);
    }
    // trust all mail server host certificates
    System.setProperty("mail.smtp.ssl.trust", "*");
    email.setSocketConnectionTimeout(settings.getConnectionTimeout());
    email.setSocketTimeout(settings.getSocketTimeout());
}
 
开发者ID:elastisys,项目名称:scale.commons,代码行数:34,代码来源:SmtpSender.java

示例10: send

import org.apache.commons.mail.Email; //导入方法依赖的package包/类
@NotInServiceMenu
@Named("Enviar Correo")
public String send(final Cliente unCliente, final Oferta unaOferta) {

	try {
		Email email = new SimpleEmail();
		email.setHostName("smtp.gmail.com");
		email.setSmtpPort(465);
		email.setAuthentication("[email protected]", "modica1234");
		email.setSSLOnConnect(true);
		email.setFrom("[email protected]", "Resto Tesis");
		email.setSubject("Ofertas para esta Semana!");
		email.setMsg(printing.ofertaToText(unaOferta));			
		email.addTo(unCliente.getCorreo());
		return email.send();
	} catch (EmailException e) {
		throw new servicio.correo.CorreoException(e.getMessage(), e);
	}
}
 
开发者ID:resto-tesis,项目名称:resto-tesis,代码行数:20,代码来源:CorreoServicio.java

示例11: sendMail

import org.apache.commons.mail.Email; //导入方法依赖的package包/类
public void sendMail(Mail mail)
        throws IOException {
    Email email = mail.getMail();

    try {
        setEncryption(email);

        email.setHostName(host);
        email.setSmtpPort(port);
        email.setCharset("UTF-8");
        email.send();
    } catch (EmailException e) {
        if (Utility.throwableContainsMessageContaining(e, "no object DCH")) {
            throw new UnhandledException("\"no object DCH\" Likely cause: the activation jar-file cannot see the mail jar-file. Different ClassLoaders?", e);
        } else {
            throw new UnhandledException(e);
        }
    }
}
 
开发者ID:imCodePartnerAB,项目名称:imcms,代码行数:20,代码来源:SMTP.java

示例12: send

import org.apache.commons.mail.Email; //导入方法依赖的package包/类
@Override
protected void send(EmailConfigDTO configDTO, ToSend message) {

    try {
        Email email = new SimpleEmail();
        email.setHostName(server);
        email.setSmtpPort(port);
        email.setAuthenticator(new DefaultAuthenticator(login, password));
        email.setSSLOnConnect(true);
        email.setFrom(from);
        email.setSubject(message.getSubject());
        email.setMsg(message.getBody());
        email.addTo(configDTO.getRecipient());
        email.send();

    } catch (EmailException ex) {
        LOGGER.error("Send E-mail exception.", ex);
    }
}
 
开发者ID:eliogrin,项目名称:CISEN,代码行数:20,代码来源:EmailMessenger.java

示例13: sendMail

import org.apache.commons.mail.Email; //导入方法依赖的package包/类
@Override
public void sendMail(String recipient, String subject, String content) throws FablabException {
	try {
		Email email = new SimpleEmail();
		email.setHostName("localhost");
		email.setSmtpPort(25);
		email.setAuthenticator(new DefaultAuthenticator("test", "test"));
		email.setFrom("[email protected]");
		email.setSubject(subject);
		email.setMsg(content);
		email.addTo(recipient);
		email.send();
	} catch (EmailException ex) {
		LOG.error("Canont send mail ", ex);
	}
}
 
开发者ID:romainGuiet,项目名称:fablab-web,代码行数:17,代码来源:MailServiceImpl.java

示例14: send

import org.apache.commons.mail.Email; //导入方法依赖的package包/类
public boolean send(String to, String subject, String tpl, Context ctx) {
	Email email = new SimpleEmail();
	email.setHostName(config.get("mail.host"));
	email.setAuthenticator(new DefaultAuthenticator(config.get("mail.user"), config.get("mail.passwd")));
	if (config.getInt("mail.ssl", 0) == 1) {
		email.setSSLOnConnect(true);
		email.setSmtpPort(config.getInt("mail.port", 465));
	} else {
		email.setSmtpPort(config.getInt("mail.port", 25));
	}
	try {
		email.setFrom(config.get("mail.from"));
		email.setSubject("["+config.get("mail.suject.prefix", "Test") + "] " + subject);
		email.setMsg(Segments.create(tpl).render(ctx).toString());
		email.addTo(to);
		email.send();
		return true;
	} catch (EmailException e) {
		log.info("Send email fail", e);
		return false;
	}
}
 
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:23,代码来源:MailServiceImpl.java

示例15: setMailServerProperties

import org.apache.commons.mail.Email; //导入方法依赖的package包/类
protected void setMailServerProperties(Email email) {
  ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();

  String host = processEngineConfiguration.getMailServerHost();
  if (host == null) {
    throw new ActivitiException("Could not send email: no SMTP host is configured");
  }
  email.setHostName(host);

  int port = processEngineConfiguration.getMailServerPort();
  email.setSmtpPort(port);

  email.setTLS(processEngineConfiguration.getMailServerUseTLS());

  String user = processEngineConfiguration.getMailServerUsername();
  String password = processEngineConfiguration.getMailServerPassword();
  if (user != null && password != null) {
    email.setAuthentication(user, password);
  }
}
 
开发者ID:iotsap,项目名称:FiWare-Template-Handler,代码行数:21,代码来源:MailActivityBehavior.java


注:本文中的org.apache.commons.mail.Email.setSmtpPort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。