org.apache.commons.mail.Email.getFromAddress()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(4.0k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中org.apache.commons.mail.Email.getFromAddress()方法的一些代码示例,展示了Email.getFromAddress()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Email.getFromAddress()方法的具体详情如下:
包路径:org.apache.commons.mail.Email
类名称:Email
方法名:getFromAddress

Email.getFromAddress介绍

[英]Gets the sender of the email.
[中]获取电子邮件的发件人。

代码示例

代码示例来源:origin: br.com.caelum.vraptor/vraptor-simplemail

  1. @Override
  2. public void send(Email email) throws EmailException {
  3. logger.info("subject => {}",email.getSubject());
  4. logger.info("from => {}",email.getFromAddress());
  5. logger.info("toAddresses => {}",email.getToAddresses());
  6. if(email instanceof SimpleEmail)
  7. send((SimpleEmail) email);
  8. else if(email instanceof HtmlEmail)
  9. send((HtmlEmail) email);
  10. else
  11. logger.info("body => unknown");
  12. }
  13. }

代码示例来源:origin: com.google.code.maven-play-plugin.org.playframework/play

  1. public static Email buildMessage(Email email) throws EmailException {
  2. String from = Play.configuration.getProperty("mail.smtp.from");
  3. if (email.getFromAddress() == null && !StringUtils.isEmpty(from)) {
  4. email.setFrom(from);
  5. } else if (email.getFromAddress() == null) {
  6. throw new MailException("Please define a 'from' email address", new NullPointerException());
  7. }
  8. if ((email.getToAddresses() == null || email.getToAddresses().isEmpty())
  9. && (email.getCcAddresses() == null || email.getCcAddresses().isEmpty())
  10. && (email.getBccAddresses() == null || email.getBccAddresses().isEmpty())) {
  11. throw new MailException("Please define a recipient email address", new NullPointerException());
  12. }
  13. if (email.getSubject() == null) {
  14. throw new MailException("Please define a subject", new NullPointerException());
  15. }
  16. if (email.getReplyToAddresses() == null || email.getReplyToAddresses().isEmpty()) {
  17. email.addReplyTo(email.getFromAddress().getAddress());
  18. }
  19. return email;
  20. }

代码示例来源:origin: br.com.caelum.vraptor/vraptor-simplemail

  1. protected void wrapUpAndSend(Email email) throws EmailException {
  2. LOGGER.debug(String.format(emailLogTemplate(),
  3. email.getSubject(),
  4. email.getFromAddress(),
  5. email.getToAddresses(),
  6. email.getHostName(),
  7. email.getSmtpPort(),
  8. email.isTLS()));
  9. email.send();
  10. }

代码示例来源:origin: com.google.code.maven-play-plugin.org.playframework/play

  1. content.append("\n\tFrom: ").append(email.getFromAddress().getAddress());
  2. content.append("\n\tReplyTo: ").append(email.getReplyToAddresses().get(0).getAddress());

代码示例来源:origin: stackoverflow.com

  1. @Autowired
  2. private MailSender mailSender;
  3. // Email is my own Pojo with from, to, subject and body properties.
  4. @Transactional(propagation = Propagation.REQUIRES_NEW)
  5. public void sendEmail(Email email)
  6. {
  7. // create email message
  8. SimpleMailMessage msg = new SimpleMailMessage();
  9. msg.setFrom(email.getFromAddress());
  10. msg.setTo(email.getToAddress());
  11. msg.setSubject(email.getSubject());
  12. msg.setText(email.getBody());
  13. // send the message using spring mail sender
  14. this.mailSender.send(msg);
  15. }

代码示例来源:origin: org.sonatype.nexus/nexus-core

  1. if (mail.getFromAddress() == null) {
  2. mail.setFrom(configuration.getFromAddress());

代码示例来源:origin: br.com.caelum.vraptor/vraptor-simplemail

  1. public void send(Email email) throws EmailException{
  2. boolean sendForReal = env.has(SEND_REAL_EMAIL) || env.getName().equals("production");
  3. if (sendForReal) {
  4. logger.info("REAL MAIL ::: {} ::: {}", email.getSubject(),
  5. email.getToAddresses());
  6. if (email.getFromAddress() == null) {
  7. email.setFrom(env.get(FROM));
  8. }
  9. if (env.has(REPLY_TO)) {
  10. email.addReplyTo(env.get(REPLY_TO));
  11. }
  12. email.setMailSession(session);
  13. try {
  14. client.sendRawEmail(new SendRawEmailRequest()
  15. .withRawMessage(mail2Content(email)));
  16. } catch (Exception e) {
  17. throw new EmailException(e);
  18. }
  19. } else {
  20. new MockMailer().send(email);
  21. }
  22. }
  23. }

代码示例来源:origin: br.com.caelum.vraptor/vraptor-simplemail

  1. public void send(Email email) throws EmailException{
  2. if (email.getFromAddress() == null) {
  3. email.setFrom(env.get(FROM), env.get(FROM_NAME));
  4. }
  5. email.setHostName(env.get(SERVER));
  6. email.setSmtpPort(Integer.parseInt(env.get(PORT)));
  7. boolean tls = env.supports(TLS);
  8. email.setTLS(tls);
  9. if (tls) {
  10. email.setAuthenticator(new DefaultAuthenticator(env.get(USERNAME),
  11. env.get(PASSWORD)));
  12. }
  13. if(env.has(REPLY_TO)) {
  14. String replyTo = env.get(REPLY_TO);
  15. email.addReplyTo(replyTo);
  16. }
  17. wrapUpAndSend(email);
  18. }

相关文章