Using Java Mail API, after sending the letter is not displayed on the mailbox.
Here is the code
public class MailAPI { static final String ENCODING = "UTF-8"; public static void sendMessage(String emailSender, String passwordSender, String emailRecipient, String subject) throws MessagingException, UnsupportedEncodingException { String content = "Some words"; String smtpHost= "smtp.yandex.ru"; String smtpPort="465"; sendSimpleMessage (emailSender, passwordSender, emailSender, emailRecipient, content, subject, smtpPort, smtpHost); } public static void sendSimpleMessage(String login, String password, String from, String to, String content, String subject, String smtpPort, String smtpHost) throws MessagingException, UnsupportedEncodingException { Authenticator auth = new MyAuthenticator(login, password); Properties props = System.getProperties(); props.put("mail.smtp.port", smtpPort); props.put("mail.smtp.host", smtpHost); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.socketFactory.port", "465"); props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.put("mail.smtp.auth", "true"); props.put("mail.debug", "true"); props.put("mail.mime.charset", ENCODING); Session session = Session.getDefaultInstance(props, auth); Message msg = new MimeMessage(session); msg.setFrom(new InternetAddress(from)); msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to)); msg.setSubject(subject); msg.setText(content); Transport.send(msg); } }