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

javax.mail.SendFailedException Invalid Addresses while sending mail

$
0
0

i had problem while sending mails useing java this is my code

package callcentersystem;

public class Email {

    private String topic = "my test";
    private String myMassage = "nothinge";

    public void untitledMethod(String to) {
        String host = "my ip adresse";
        Properties properties = System.getProperties();
        properties.setProperty("mail.smtp.host", host);
        Session session = Session.getDefaultInstance(properties);
        try {
            MimeMessage message = new MimeMessage(session);
            message.setFrom(new InternetAddress(utils.Constants.From));
            message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
            message.setSubject(topic);
            message.setText(myMassage);
            Transport transport = session.getTransport("smtp");
            transport.send(message);
            System.out.println("Sent message successfully....");
        } catch (MessagingException mex) {
            System.out.println("the massage didnt send");
            throw new RuntimeException(mex);
        }
    }
}

and this is my crash massage

the massage didnt send
Exception in thread "main" java.lang.RuntimeException:        javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 530 SMTP authentication is required.

at callcentersystem.Email.untitledMethod(Email.java:33)
at callcentersystem.CallCenterSystem.main(CallCenterSystem.java:10)
Caused by: javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 530 SMTP authentication is    required.

at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1446)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:736)
at javax.mail.Transport.send0(Transport.java:191)
at javax.mail.Transport.send(Transport.java:120)
at callcentersystem.Email.untitledMethod(Email.java:29)
... 1 more
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 530 SMTP authentication is required.

at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1344)
... 5 more

i tried all ways to solve this problem but it dosent work and i setup a hmailserver administrator and i use it that solved my localhost problem


Viewing all articles
Browse latest Browse all 30081

Trending Articles



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