String From = "sender@here.com";
String To = "receiver@there.com";
String Subject = "Test";
String body = "Test Body";
Session session = Session.getInstance(this.getMailProperties(SMTP_PORT), null);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(From));
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(To, false));
msg.setSubject(Subject);
msg.setText(body);
msg.setHeader("X-Mailer", "musala");
msg.setSentDate(new Date());
Transport transport = null;
try
{
transport = session.getTransport("smtp");
transport.connect(HOST_NAME, SMTP_PORT, "ddd", "ddd");
assertEquals(0, this.server.getMessages().size());
transport.sendMessage(msg, InternetAddress.parse(To, false));
assertEquals(1, this.server.getMessages().size());
transport.sendMessage(msg, InternetAddress.parse("dimiter.bakardjiev@musala.com", false));