Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29748

Javamail: Email leaves successfully from program but is not delivered Windows Server 2012 r2 [closed]

$
0
0

I am severely stuck on this problem.

My program successfully delivers emails from my Windows 10 PC and Windows Server 2012 R2 Essential but sending it through any other Windows Server 2012 versions shows as successfully sent but the email is not delivered.

Have tried all combinations of SSL/TLS/No authentication as well as all ports 465/587/26.

This is the code that i'm using

    String port = "26";
    // Recipient's email ID needs to be mentioned.
    String to = "*****@gmail.com";

    // Sender's email ID needs to be mentioned
    String host = "mail.*****.com.pk";
    String username = "sales@*****.com.pk";//change accordingly
    String password = "*****";//change accordingly

    Properties props = new Properties();
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.host", host);
    props.put("mail.smtp.port", port);
    // SSL Factory
    // props.put("mail.smtp.socketFactory.class",
    //           "javax.net.ssl.SSLSocketFactory");
    props.put("mail.smtp.starttls.enable", "false");

    System.out.println("TLS Settings False");
    System.out.println("Sending with port: " + port);

    // Get the Session object.
    Session session = Session.getInstance(props,
            new javax.mail.Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(username, password);
                }
            });

    try {
        // Create a default MimeMessage object.
        Message message = new MimeMessage(session);

        // Set From: header field of the header.
        message.setFrom(new InternetAddress(username));

        // Set To: header field of the header.
        message.setRecipients(Message.RecipientType.TO,
                InternetAddress.parse(to));

        // Set Subject: header field
        message.setSubject("Testing Subject from burhanisolutions.com.pk");

        // Now set the actual message
        message.setText("Hello, this is sample for to check send " +
                "email using JavaMailAPI on personal workstation ");

        // Send message
        Transport.send(message);

        System.out.println("Sent message successfully....");

    } catch (MessagingException e) {
        throw new RuntimeException(e);
    }

I have also tried using Jodd Mail Library which replicates the same situation which gives me reason to believe the OS is the issue here


Viewing all articles
Browse latest Browse all 29748

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>