Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.security.Security;
- import java.util.Properties;
- import javax.mail.Authenticator;
- import javax.mail.Message;
- import javax.mail.MessagingException;
- import javax.mail.PasswordAuthentication;
- import javax.mail.Session;
- import javax.mail.Transport;
- import javax.mail.internet.InternetAddress;
- import javax.mail.internet.MimeMessage;
- public class Main {
- public static void main(String[] args) {
- String username = "noreply@gtanksonline.com";
- String password = "ATXzMtSM";
- Properties props = new Properties();
- props.put("mail.smtp.host", "gtanksonline.com");
- /* props.put("mail.smtp.socketFactory.port", "465");
- props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
- props.put("mail.smtp.socketFactory.fallback", "false");
- props.put("mail.smtp.auth", "true");*/
- props.put("mail.smtp.port", "25");
- props.put("mail.smtp.ssl.trust", "*");
- Session session = Session.getInstance(props, new Authenticator() {
- protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication(username, password);
- }
- });
- try {
- Message message = new MimeMessage(session);
- message.setFrom(new InternetAddress(username));
- message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("scpacker19@gmail.com"));
- message.setSubject("TEST");
- message.setText("gtanks online");
- Transport.send(message);
- } catch (MessagingException e) {
- throw new RuntimeException(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement