Java Code Examples for org.springframework.mail.SimpleMailMessage#getTo()

The following examples show how to use org.springframework.mail.SimpleMailMessage#getTo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MockMailSender.java    From openregistry with Apache License 2.0 6 votes vote down vote up
@Override
public void send(SimpleMailMessage msg) throws MailException {
	// Write the message to the console
	System.out.println("MockMailSender: mock email message start === ");
	String to = "";
	for (String addr : msg.getTo()) {
		if (to.length() > 0) {
			to+=", ";
		}
		to += addr;
	}
	System.out.println("To: "+to);
	System.out.println("From: "+msg.getFrom());
	System.out.println("Subject: "+msg.getSubject());
	System.out.println("Contents: "+msg.getText());
	System.out.println("MockMailSender: mock email message end === ");
}
 
Example 2
Source File: TestMailSender.java    From haven-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void send(SimpleMailMessage msg) throws MailException {
    String[] tos = msg.getTo();
    for(String to: tos) {
        mailbox.computeIfAbsent(to, (k) -> new CopyOnWriteArrayList<>()).add(msg);
        log.info("Receive for {}, \n message: {} ", to, msg);
    }
}