I'm trying to send an E-Mail using Java (Java 10), but i have this error:
javax.mail.SendFailedException: No recipient addresses
at javax.mail.Transport.send0(Transport.java:154)
at javax.mail.Transport.send(Transport.java:124)
at Mail.mandaMail(Mail.java:282)
at View$1.actionPerformed(View.java:68)
[...]
Process finished with exit code 0
This is the code of the class throwing error at line "282"
variables i use:
mittente = "***************@******.com"
password = ******
host = mail.mydomain.com
destinatario = ******@gmail.com
I'm using a Aruba mail server but i don't think the configuration for it is wrong
public void mandaMail(String destinatario) throws MessagingException, NoClassDefFoundError {
//Get the session object
Properties props = new Properties();
props.put("mail.smtp.host",host);
props.put("mail.smtp.auth", true);
Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(mittente,password);
}
});
//Compose the message
Message message = new Message(session)(**Overriding all the methods*)
message.setFrom(new InternetAddress(mittente));
//A:
message.addRecipient(Message.RecipientType.TO,new InternetAddress(destinatario, true));
//CC
message.addRecipient(Message.RecipientType.CC, new InternetAddress());
message.setSubject("PFSistemi -"+intervento.toString());
message.setText(this.contenuto.toString());
//send the message
Transport.send(message);
System.out.println("message sent successfully...");
}
Maybe this problem is caused by overriding all the method of the Message class, i use this class because the class MimeMessage give me a tons of problems that nobody can resolve (LOL)