Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MailSender
- {
- public static void send(String adress, String message)
- {
- try
- {
- String to = adress;
- String smtpHost = "mail.gmx.com";
- String from = "mailactivator@gmx.com";
- String username = "mailactivator@gmx.com";
- String password = "mailactivator@123578951";
- Properties props = new Properties();
- props.put("mail.smtp.host", smtpHost);
- props.put("mail.smtp.auth", "true");
- Session session = Session.getDefaultInstance(props);
- session.setDebug(true);
- MimeMessage msg = new MimeMessage(session);
- msg.setFrom(new InternetAddress(from));
- msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
- msg.setSubject("PaladiumPVP");
- msg.setText(message);
- Transport tr = session.getTransport("smtp");
- tr.connect(smtpHost, username, password);
- msg.saveChanges();
- tr.sendMessage(msg, msg.getAllRecipients());
- tr.close();
- }
- catch(NoSuchProviderException e)
- {
- System.err.println("Pas de transport disponible pour ce protocole");
- System.err.println(e);
- }
- catch(AddressException e)
- {
- System.err.println("Adresse invalide");
- System.err.println(e);
- }
- catch(MessagingException e)
- {
- System.err.println("Erreur dans le message");
- System.err.println(e);
- }
- }
- }
Add Comment
Please, Sign In to add comment