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


Java SimpleEmail.addTo方法代码示例

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


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

示例1: sendSimpleEmail

import org.apache.commons.mail.SimpleEmail; //导入方法依赖的package包/类
public void sendSimpleEmail(String email_to, String subject, String msg) {
    SimpleEmail email = new SimpleEmail();
    try {
        email.setDebug(debug);
        email.setHostName(smtp);
        email.addTo(email_to);
        email.setFrom(email_from);
        email.setAuthentication(email_from, email_password);
        email.setSubject(subject);
        email.setMsg(msg);
        email.setSSL(ssl);
        email.setTLS(tls);
        email.send();
    } catch (EmailException e) {
        System.out.println(e.getMessage());
    }
}
 
开发者ID:tiagorlampert,项目名称:sAINT,代码行数:18,代码来源:SendEmail.java

示例2: envia

import org.apache.commons.mail.SimpleEmail; //导入方法依赖的package包/类
public static void envia(Registrar reg) {
    try {
        SimpleEmail email = new SimpleEmail();
        email.setHostName("10.1.8.102");
        email.addTo("[email protected]");
        //email.addCc("[email protected]");
        email.addCc("[email protected]");
        email.addCc("[email protected]");
        email.addCc("[email protected]");
        //email.addCc("[email protected]");
        //email.addCc("[email protected]");
        email.setFrom("[email protected]");
        email.setSubject("Error en tablealias");
        String msg = String.format("%nServidor %s, pathInfo %s%nParametros %s ",reg.getNomServidor(), reg.getPagAccesa(), reg.getParametros());
        email.setMsg("Categoria: " + reg.getCategoria() + " , Descripcion " + reg.getDescripcion() + msg + " \n Navegador:" + reg.getExplorador());
        email.send();
        
    } catch (EmailException ex1) {
        ex1.printStackTrace();
    }   
        
}
 
开发者ID:MxSIG,项目名称:TableAliasV60,代码行数:23,代码来源:Correo.java

示例3: sendText

import org.apache.commons.mail.SimpleEmail; //导入方法依赖的package包/类
@Override
public boolean sendText(String to, String subject, String content) throws EmailException {
	SimpleEmail email = new SimpleEmail();
	email.setHostName(host);// 设置使用发电子邮件的邮件服务器
	email.addTo(to);
	email.setAuthentication(user, password);
	email.setFrom(from);
	email.setSubject(subject);
	email.setMsg(content);
	if (port == 465) {
		email.setSSLOnConnect(true);
		email.setSslSmtpPort(Integer.toString(port)); // 若启用,设置smtp协议的SSL端口号
	}
	else {
		email.setSmtpPort(port);
	}
	email.send();
	return true;
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:20,代码来源:MailClientImpl.java

示例4: sendSimpleEmail

import org.apache.commons.mail.SimpleEmail; //导入方法依赖的package包/类
/**
 * Test sending an {@link SimpleEmail} rather than a {@link SmtpMessage}.
 */
@Test
public void sendSimpleEmail() throws Exception {
    assertThat(this.sslMailServer.getReceivedMessages().length, is(0));

    SimpleEmail email = new SimpleEmail();
    email.setFrom("[email protected]");
    email.setSubject("subject");
    email.setMsg("content");
    email.addTo("[email protected]");
    email.setSentDate(UtcTime.now().toDate());
    SmtpSender sender = new SmtpSender(email, new SmtpClientConfig("localhost", SMTP_SSL_PORT,
            new SmtpClientAuthentication(USERNAME, PASSWORD), true));
    sender.call();

    // check mailbox after sending
    MimeMessage[] receivedMessages = this.sslMailServer.getReceivedMessages();
    assertThat(receivedMessages.length, is(1));
    assertThat(receivedMessages[0].getSubject(), is("subject"));
    assertThat(receivedMessages[0].getSentDate(), is(FrozenTime.now().toDate()));
    Object expectedContent = "content";
    assertThat(GreenMailUtil.getBody(receivedMessages[0]).trim(), is(expectedContent));
}
 
开发者ID:elastisys,项目名称:scale.commons,代码行数:26,代码来源:TestSmtpSender.java

示例5: sendNormalEmail

import org.apache.commons.mail.SimpleEmail; //导入方法依赖的package包/类
/**
 * Send a verification email to the user's email account if exist.
 * 
 * @param user
 */
public void sendNormalEmail(String subject, String content, String[] addresses ) {
	if ( StringUtil.checkNotEmpty(subject) && StringUtil.checkNotEmpty(content) ) {
		try {
			String emailSmtp = GameDataManager.getInstance().getGameDataAsString(GameDataKey.EMAIL_SMTP, "mail.xinqihd.com");
			SimpleEmail email = new SimpleEmail();
			email.setHostName(emailSmtp);
			email.setAuthenticator(new DefaultAuthenticator(EMAIL_FROM, "[email protected]"));
			email.setFrom(EMAIL_FROM);
			email.setSubject(subject);
			email.setMsg(content);
			email.setCharset("GBK");
			for ( String address : addresses) {
				if ( StringUtil.checkNotEmpty(address) ) {
					email.addTo(address);
				}
			}
			email.send();
		} catch (EmailException e) {
			logger.debug("Failed to send normal email", e);
		}
	}
}
 
开发者ID:wangqi,项目名称:gameserver,代码行数:28,代码来源:EmailManager.java

示例6: sendTextEmail

import org.apache.commons.mail.SimpleEmail; //导入方法依赖的package包/类
@Override
public void sendTextEmail(String to, String subject, String textBody) throws ServiceException {
	SimpleEmail email = new SimpleEmail();

	try {
		setupEmail(email);
		validateAddress(to);
		email.addTo(to);
		email.setSubject(subject);
		email.setMsg(textBody);
		email.send();
	} catch (EmailException e) {
		log.error("ZZZ.EmailException. To: " + to + " Subject: " + subject, e);
		throw new ServiceException("Unable to send email.", e);
	}
}
 
开发者ID:SmarterApp,项目名称:TechnologyReadinessTool,代码行数:17,代码来源:EmailServiceImpl.java

示例7: enviaEmailSimples

import org.apache.commons.mail.SimpleEmail; //导入方法依赖的package包/类
/**
 * envia email simples (smente texto)
 * Nome remetente, e-mail remetente, nome destinatario, e-mail destinatario,
 * assunto, mensagem
 * @param nomeRemetente
 * @param nomeDestinatario
 * @param emailRemetente
 * @param emailDestinatario
 * @param assunto
 * @param mensagem
 * @throws EmailException
 */
public void enviaEmailSimples(String nomeRementente, String emailRemetente,
        String nomeDestinatario, String emailDestinatario,
        String assunto, StringBuilder mensagem) throws EmailException {

    SimpleEmail email = new SimpleEmail();
    email.setHostName("smtp.hslife.com.br"); // o servidor SMTP para envio do e-mail
    email.addTo(emailDestinatario, nomeDestinatario); //destinatário
    email.setFrom(emailRemetente, nomeRementente); // remetente
    email.setSubject(assunto); // assunto do e-mail
    email.setMsg(mensagem.toString()); //conteudo do e-mail
    email.setAuthentication("[email protected]", "real123");
    //email.setSmtpPort(465);
    //email.setSSL(true);
    //email.setTLS(true);
    email.send();
}
 
开发者ID:herculeshssj,项目名称:imobiliariaweb,代码行数:29,代码来源:EmailService.java

示例8: sendEmail

import org.apache.commons.mail.SimpleEmail; //导入方法依赖的package包/类
public static void sendEmail(String emailAddr, String verifyCode) {
	
	SimpleEmail email = new SimpleEmail();
	email.setHostName("smtp.163.com");
	email.setAuthentication("[email protected]", "xingji19890326");
	email.setCharset("UTF-8");
	try{
		email.addTo(emailAddr);
		email.setFrom("[email protected]");
		email.setSubject("Actsocial dashborad Check");
		email.setMsg(verifyCode);
		email.send();
	}catch(EmailException e){
		e.printStackTrace();
	}
}
 
开发者ID:yancykim,项目名称:support,代码行数:17,代码来源:ValidatorTool.java

示例9: sendEmail

import org.apache.commons.mail.SimpleEmail; //导入方法依赖的package包/类
public static void sendEmail(String emailAddr, String verifyCode) {
	
	SimpleEmail email = new SimpleEmail();
	email.setHostName("smtp.gmail.com");
	email.setAuthentication("[email protected]", "xingji19890326");
	email.setCharset("UTF-8");
	try{
		email.addTo(emailAddr);
		email.setFrom("[email protected]");
		email.setSubject("Actsocial dashborad Check");
		email.setMsg(verifyCode);
		email.send();
	}catch(EmailException e){
		e.printStackTrace();
	}
}
 
开发者ID:yancykim,项目名称:support,代码行数:17,代码来源:EmailUtil.java

示例10: send

import org.apache.commons.mail.SimpleEmail; //导入方法依赖的package包/类
public void send(EmailRequest request) throws EmailException, MalformedURLException {

		SimpleEmail email = new SimpleEmail();
		email.setFrom(request.getFromEmail(), request.getFromName());
		email.setSubject(request.getSubject());
		// Split multiple email addresses on either comma or semicolon
		String[] toAddresses = request.getToEmail().split(",|;");
		for (String thisToAddress : toAddresses) {
			email.addTo(thisToAddress);
		}
		email.setMsg(request.getTextBody());

		// Send email to multiple recipients even if one email address is invalid.
		email.setSendPartial(true);

		addStandardDetails(email);
		email.send();
	}
 
开发者ID:IHTSDO,项目名称:snomed-release-service,代码行数:19,代码来源:EmailSender.java

示例11: testSimpleEmail

import org.apache.commons.mail.SimpleEmail; //导入方法依赖的package包/类
@Test
public void testSimpleEmail()
    throws EmailException, MessagingException
{
    Smtp smtp = WERVAL.application().plugin( Smtp.class );
    assertThat( smtp, notNullValue() );

    SimpleEmail email = smtp.newSimpleEmail();
    email.setFrom( "[email protected]" );
    email.addTo( "[email protected]" );
    email.setSubject( "Simple Email" );
    email.send();

    List<WiserMessage> messages = wiser.getMessages();
    assertThat( messages.size(), is( 1 ) );
    WiserMessage message = messages.get( 0 );
    assertThat( message.getMimeMessage().getHeader( "From" )[0], equalTo( "[email protected]" ) );
    assertThat( message.getMimeMessage().getHeader( "To" )[0], equalTo( "[email protected]" ) );
    assertThat( message.getMimeMessage().getHeader( "Subject" )[0], equalTo( "Simple Email" ) );

    MetricRegistry metrics = WERVAL.application().plugin( Metrics.class ).metrics();
    assertThat( metrics.meter( "io.werval.modules.smtp.sent" ).getCount(), is( 1L ) );
    assertThat( metrics.meter( "io.werval.modules.smtp.errors" ).getCount(), is( 0L ) );

    HealthCheckRegistry healthChecks = WERVAL.application().plugin( Metrics.class ).healthChecks();
    assertTrue( healthChecks.runHealthCheck( "smtp" ).isHealthy() );
}
 
开发者ID:werval,项目名称:werval,代码行数:28,代码来源:SmtpPluginTest.java

示例12: send

import org.apache.commons.mail.SimpleEmail; //导入方法依赖的package包/类
public static void send(String recepient, String subject, String message) throws EmailException, ConfigurationException {
	SimpleEmail email = new SimpleEmail();
	Configurable config = Configuration.getInstance();
	email.setHostName(config.getStringValue("profile.smtp.host"));
	email.setSmtpPort(config.getIntValue("profile.smtp.port"));
	email.setAuthenticator(new DefaultAuthenticator(config.getStringValue("profile.username"), config.getStringValue("profile.password")));
	email.setSSLOnConnect(true);
	email.setFrom(config.getStringValue("profile.email"), config.getStringValue("profile.name"));
	email.addTo(recepient);
	email.setSubject(subject);
	email.setMsg(message);
	email.send();
}
 
开发者ID:IvanTrendafilov,项目名称:notifier-app,代码行数:14,代码来源:EmailSender.java

示例13: doGet

import org.apache.commons.mail.SimpleEmail; //导入方法依赖的package包/类
/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
 *      response)
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response)
		throws ServletException, IOException {
	String trocaform = request.getParameter("trocaform");
	if (trocaform != null) {
		StringBuilder sb = new StringBuilder();
		sb.append(
				"<form role='form' class='form-group' id='formrecupera' action='/EstacionamentoWeb/recuperar' method='post' >");
		sb.append("<label>Login: </label>");
		sb.append("<input class='form-control' type='text' name='login' size='20' required='required'><br>");
		sb.append("<label>Email: </label>");
		sb.append("<input class='form-control' type='email' size='30' name='email' required='required'><br>");
		sb.append("<input class='btn btn-default' type='submit' value='Recuperar'>");
		sb.append("</form>");

		response.getWriter().write(sb.toString());
		response.setStatus(200);
	} else {
		String login = request.getParameter("login");
		String email = request.getParameter("email");

		UsuarioBean usuario = new UsuarioBean();
		usuario = UsuarioDao.getUsuario(login);

		String scheme = request.getScheme();
		String serverName = request.getServerName();
		int serverPort = request.getServerPort();
		String contextPath = request.getContextPath();
		String resultpath = scheme + "://" + serverName + ":" + serverPort + contextPath;

		Random gerador = new Random();

		String aleatorio = "";

		for (int i = 1; i < 65; i++) {
			aleatorio += String.valueOf(gerador.nextInt(10));
		}

		usuario.setHashrecuperasenha(UsuarioDao.geraHashCriptografada(aleatorio));
		UsuarioDao.insereHashRecuperaSenha(usuario);

		SimpleEmail enviaemail = new SimpleEmail();

		String status = null;

		if ((usuario.getEmail() != null && usuario.getLogin() != null)
				&& (usuario.getEmail().equals(email) && usuario.getLogin().equals(login))) {
			try {
				enviaemail.setDebug(true);
				enviaemail.setHostName("smtp.gmail.com");
				enviaemail.setSmtpPort(587);
				enviaemail.setAuthentication("Seu Login Aqui", "Sua Senha Aqui");
				enviaemail.setStartTLSEnabled(true);
				enviaemail.addTo(usuario.getEmail());
				enviaemail.setFrom("Seu Email Aqui");
				enviaemail.setSubject("Recuperação de Senha - EstacionamentoWeb");
				enviaemail.setMsg("Para recuperar a sua senha clique no link a seguir: " + resultpath
						+ "/novasenha.jsp?hash=" + usuario.getHashrecuperasenha());
				enviaemail.send();
			} catch (Exception e) {
				System.out.println(e);
			}
			status = "Siga as orientações enviadas por email.";
			response.sendRedirect("/EstacionamentoWeb/login.jsp?alert=info&status=" + status);
		} else {
			status = "Login ou Email inválido!";
			response.sendRedirect("/EstacionamentoWeb/login.jsp?alert=danger&status=" + status);
		}
	}
}
 
开发者ID:rasertux,项目名称:EstacionamentoWeb,代码行数:74,代码来源:RecuperaSenha.java

示例14: sendEmailToBasicSetup

import org.apache.commons.mail.SimpleEmail; //导入方法依赖的package包/类
private static void sendEmailToBasicSetup(String recipentEmail, String subject, String message) throws Exception {
    if (IS_SMTPS_REQUIRED != null && IS_SMTPS_REQUIRED.equals("true")) {
        sendEmailTo(recipentEmail, subject, message);
        return;
    }
    log.debug("Email settings: ");
    log.debug("Hostname: " + MAIL_SERVER);
    log.debug("Recipent: " + recipentEmail);
    log.debug("Subject: " + subject);
    log.debug("Message: " + message);

    SimpleEmail email = new SimpleEmail();
    email.setHostName(MAIL_SERVER);
    email.addTo(recipentEmail);
    email.setSubject(subject);
    email.setMsg(message);

    if (ADMIN_NAME != null) {
        log.debug("With admin name send: yes (" + ADMIN_NAME + ")");
        email.setFrom(ADMIN_EMAIL, ADMIN_NAME);
    } else {
        log.debug("With admin name send: no");
        email.setFrom(ADMIN_EMAIL);
    }
    log.debug("Admin email: " + ADMIN_EMAIL);

    if (TLS != null && TLS.equals("true")) {
        log.debug("TLS: yes");
        email.setTLS(true);
    } else {
        log.debug("TLS: no");
    }

    if (MAIL_SERVER_PORT != null) {
        log.debug("Server port explicity set: yes (" + MAIL_SERVER_PORT + ")");
        email.setSmtpPort(Integer.valueOf(MAIL_SERVER_PORT));

        if (email.isTLS()) {
            log.debug("ssl port set: yes");
            email.setSslSmtpPort(MAIL_SERVER_PORT);
        } else {
            log.debug("ssl port set: no");
        }
    }

    log.debug("Authentication email: " + ADMIN_EMAIL_USERNAME);
    log.debug("Authentication password: " + PASSWORD);
    email.setAuthentication(ADMIN_EMAIL_USERNAME, PASSWORD);
    email.send();
}
 
开发者ID:glycoinfo,项目名称:eurocarbdb,代码行数:51,代码来源:SendCustomMail.java

示例15: sendEmailTo

import org.apache.commons.mail.SimpleEmail; //导入方法依赖的package包/类
private static void sendEmailTo(String addToEmail, String subject, String message) throws Exception {
    SimpleEmail email = new SimpleEmail();
    if (PASSWORD != null) {
        email.setAuthenticator(new DefaultAuthenticator(ADMIN_EMAIL_USERNAME, PASSWORD));
    }

    email.setHostName(MAIL_SERVER);
    if (MAIL_SERVER_PORT != null) {

        email.setSmtpPort(Integer.parseInt(MAIL_SERVER_PORT));

    }
    if (TLS != null && TLS.equals("true")) {
        email.setTLS(true);
    }

    email.getMailSession().getProperties().put("mail.smtps.auth", "true");


    if (MAIL_SERVER_PORT != null) {
        email.getMailSession().getProperties().put("mail.smtps.port", MAIL_SERVER_PORT);
        email.getMailSession().getProperties().put("mail.smtps.socketFactory.port", MAIL_SERVER_PORT);
    } else {
        email.getMailSession().getProperties().put("mail.smtps.port", "25");
        email.getMailSession().getProperties().put("mail.smtps.socketFactory.port", "25");
    }

    email.getMailSession().getProperties().put("mail.smtps.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    email.getMailSession().getProperties().put("mail.smtps.socketFactory.fallback", "false");
    if (TLS != null && TLS.equals("true")) {
        email.getMailSession().getProperties().put("mail.smtp.starttls.enable", "true");
    }



    email.addTo(addToEmail);
    if (ADMIN_NAME != null) {
        email.setFrom(ADMIN_EMAIL, ADMIN_NAME);
    } else {
        email.setFrom(ADMIN_EMAIL);
    }

    email.setSubject(subject);

    email.setMsg(message);

    email.send();


}
 
开发者ID:glycoinfo,项目名称:eurocarbdb,代码行数:51,代码来源:SendCustomMail.java


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