failure in simulating an automatic mail sending using a local smtp server
843834Dec 3 2007 — edited Dec 4 2007hello
i'm trying to simulate a local sending of mails using the smtp server hmail. it's a simple mail sending from an adress to another that i added in the smtp server using a dummy DNS just for the test "test.com". as shown in the source code and in the debug trace of javamail, the program is connecting to the local server but appearently, it's not recognizing the adresses, it's always ok for the sender's adress, but never for the reciepient adress. i don't know if it's because of my application written in java or because of my local smtp server.
here is the source code "really simple on":
import java.io.*;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
public class Envoi {
/** Destinataire du message. */
protected String message_dest = "structure_test1@test.com";
/* Objet du message. */
protected String message_objet = "that's it ";
/** Texte du message. */
protected String message_corps =
"yeeahhh";
/** Objet session de JavaMail. */
protected Session session;
/** Objet message de JavaMail. */
protected Message mesg;
public void envoyerMail() {
// Nous devons passer les informations au serveur de messagerie sous
// forme de propri�t�s car JavaMail en comporte beaucoup...
Properties props = new Properties();
// Votre r�seau doit donner au serveur SMTP local le nom "nom_du_serveur_smtp"
props.put("mail.smtp.host", "127.0.0.1");
// Cr�er l�objet Session.
session = Session.getInstance(props, null);
session.setDebug(true); //activer le mode verbeux !
try {
// Cr�er un message.
mesg = new MimeMessage(session);
// Adresse From - Indiquer la provenance du message
mesg.setFrom(new InternetAddress("test1@test.com"));
// Adresse TO.
InternetAddress toAddress = new InternetAddress(message_dest);
mesg.addRecipient(Message.RecipientType.TO, toAddress);
// Objet.
mesg.setSubject(message_objet);
// Corps du message.
mesg.setText(message_corps);
// Enfin, envoyer le message !
Transport.send(mesg);
} catch (MessagingException ex) {
while ((ex = (MessagingException)ex.getNextException()) != null) {
ex.printStackTrace();
}
}
}
/** Programme principal*/
public static void main(String[] av) {
Envoi env = new Envoi();
env.envoyerMail();
}
}
and here is the output of the program :
init:
deps-jar:
compile:
run:
DEBUG: setDebug: JavaMail version 1.4.1
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "127.0.0.1", port 25, isSSL false
220 welcome to hajer smtp
DEBUG SMTP: connected to host "127.0.0.1", port: 25
EHLO Hajer
250-hmailserver
250-SIZE 150000
250 AUTH LOGIN
DEBUG SMTP: Found extension "SIZE", arg "150000"
DEBUG SMTP: Found extension "AUTH", arg "LOGIN"
DEBUG SMTP: use8bit false
MAIL FROM:<test1@test.com>
250 OK
RCPT TO:<structure_test1@test.com>
550 Domain has been disabled.
DEBUG SMTP: Invalid Addresses
DEBUG SMTP: structure_test1@test.com
DEBUG SMTP: Sending failed because of invalid destination addresses
RSET
250 OK
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 Domain has been disabled.
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1294)
com.sun.mail.smtp.SMTPAddressFailedException: 550 Domain has been disabled.
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1145)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:635)
at javax.mail.Transport.send0(Transport.java:189)
at javax.mail.Transport.send(Transport.java:118)
at Envoi.envoyerMail(Envoi.java:67)
at Envoi.main(Envoi.java:78)
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 Domain has been disabled.
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1145)
... 5 more
QUIT
221 goodbye
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:635)
at javax.mail.Transport.send0(Transport.java:189)
at javax.mail.Transport.send(Transport.java:118)
at Envoi.envoyerMail(Envoi.java:67)
at Envoi.main(Envoi.java:78)
BUILD SUCCESSFUL (total time: 1 second)
i just want to be sure that the problem is not providing from my application, i mean that i want to be sure that there is no properties errors. if it's okey with my code, i will ask for a solution in the hmail forum..
thank you all