Seguinte pessoal estou tentando enviar email usando a Javax.mail, o email esta sendo enviado mas tanto o (REMETENTE, ASSUNTO, PARA) quando chega para a pessoa esta aparecendo com:
(remetente não conhecido)
(sem assunto)
E na mensagem não aparece o endereço de para quem enviei.
Somente o texto da mensagem que aparece!
Alguma sugestão?
aqui meu código:
[code]
public class mail {
public static void main(String[] args) throws MessagingException {
try {
new mail().run();
} catch (UnsupportedEncodingException e) {
System.out.println("UnsupportedEncodingException: "+e.getMessage());
e.printStackTrace();
}
}
private void run() throws MessagingException, UnsupportedEncodingException {
try{
MimeMessage message = new MimeMessage(getSession());
InternetAddress address = new InternetAddress("info@idip.com.br","Jonatha Chaves");
message.addRecipient(RecipientType.TO, new InternetAddress("jonatha.chaves@gmail.com"));
message.setFrom(address);
message.setSubject("JAVA","iso-8859-1");
System.out.println(message.getSubject());
message.setContent("teste do brasil2", "text/plain");
message.saveChanges();
System.out.println("Iniciando o envio!");
Transport.send(message);
System.out.println("Mensagem enviada");
}
catch (AddressException e) {
System.out.println("erro de endereço: "+e.getMessage());
}
catch (MessagingException e) {
System.out.println("erro de envio: "+e.getMessage());
}
}
private Session getSession() {
Authenticator authenticator = new Authenticator();
Properties properties = new Properties();
properties.setProperty("mail.smtp.submitter", authenticator.getPasswordAuthentication().getUserName());
properties.setProperty("mail.smtp.auth", "true");
properties.setProperty("mail.smtp.host", "mail.idip.com.br");
properties.setProperty("mail.smtp.port", "25");
return Session.getInstance(properties, authenticator);
}
private class Authenticator extends javax.mail.Authenticator {
private PasswordAuthentication authentication;
public Authenticator() {
String username = "usuario";
String password = "senha";
authentication = new PasswordAuthentication(username, password);
}
protected PasswordAuthentication getPasswordAuthentication() {
return authentication;
}
}
}[/code]