Hi, when I try to send a e-mail a error message appear, because my e-mail server need do log in/ validate, how can I validate in my smtp mail server??? Anyone knows???
Message Error:
ERROR SENDING E-MAIL: sun.net.smtp.SmtpProtocolException: 553 UTILIZE A AUTENTICACAO PARA ENVIO DE MENSAGENS/THIS SERVER IS TO BE USED WITH AUTHENTICATION (#5.7.1)
The code snipped provided by JSC states that it will not work if your mail server requires validation:
// Send Email
// This clip can be used in a button action
// method to send an e-mail via SMTP
// (if no authentication is required from the mailserver)
//TODO: Create a Text Area component on the page and
// a Button, place this code in the Button's action method
//TODO: set the from, to addresses and the mail server
String from = "From address"; // from address
String to = "To address"; // to address
String mailserver = "SMTP mail server name";
// please note that if your mail server requires authentication,
// this code may not work
try {
sun.net.smtp.SmtpClient client = new sun.net.smtp.SmtpClient( mailserver );
client.from(from);
client.to(to);
java.io.PrintStream message = client.startMessage();
message.println("To: " + to);
// TODO: set the subject line
message.println("Subject: Customer Comments");
// TODO: set the body of the message
message.println(getTextArea1().getValue().toString());
client.closeServer();
} catch (java.io.IOException ex) {
// in the case of an exception, print a message to the output log
log("ERROR SENDING EMAIL:"+ex);
}
1. If it requires authentication, how do you specify that?
2. I tried the email tutorial and it works without authentication. I would like to know what decides whether you need to get authenticated or not. If I did not have authentication code in my code, how can mail server accept my message. I am a bit surprised that it works. ;)
3. For email, do you need to apply similar concept like database connection pooling? If does, how do you do that?
1. If it requires authentication, how do you specify
that?
I think you will have to rework the code a bit to use javax.mail.* I found
http://www.javacommerce.com/destination65673/18274/SendMailUsingAuthentication.java
as an example.
2. I tried the email tutorial and it works without
authentication. I would like to know what decides
whether you need to get authenticated or not. If I
did not have authentication code in my code, how can
mail server accept my message. I am a bit surprised
that it works. ;)
The receiving server decides what it will accept for transport. It can do it based on DNS, authentication or whatever. Open relays (SMTP servers which accept emails from everywhere to forward) are considered bad these days.
3. For email, do you need to apply similar concept
like database connection pooling? If does, how do you
do that?
I have developed an Excel VBA Application which sends mails to any number of recipients even from any email addresses without verifying with the password!
But, thats an Excel VBA Application, i dont think it would be of your interest.