Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args){
- final String username = "labtime@mail.labtime.ufg.br";
- final String password = "Lt28xm37o1";
- Properties props = new Properties();
- props.put("mail.smtp.auth", true);
- props.put("mail.smtp.starttls.enable", true);
- props.put("mail.smtp.ssl.trust", "192.168.1.28");
- props.put("mail.smtp.host", "192.168.1.28");
- props.put("mail.smtp.port", "10587");
- Session session = Session.getInstance(props,
- new javax.mail.Authenticator() {
- protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication(username, password);
- }
- });
- try {
- Message message = new MimeMessage(session);
- message.setFrom(new InternetAddress("labtime@mail.labtime.ufg.br"));
- message.setRecipients(Message.RecipientType.TO,
- InternetAddress.parse("rhandyrafhael@gmail.com"));
- message.setSubject("Dear Testing Subject");
- message.setText("Dear Mail Crawler,"
- + "\n\n No spam to my email, please!");
- Transport.send(message);
- System.out.println("Done");
- } catch (MessagingException e) {
- throw new RuntimeException(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement