I would like to send email without authentication using java. Can someone help me?
With authentication, I do it as follows:
public void sendEmail() throws EmailException{
SimpleEmail email = new SimpleEmail();
email.setHostName("smtp.gmail.com");
email.setSmtpPort(465);
email.addTo("[email protected]", "XXXX");
email.setFrom("[email protected]","XXXXX");
email.setSubject("testando . . .");
email.setMsg("testando 1");
email.setSSL(true);
email.setAuthentication("[email protected]", "XXXXX");
email.send();
}
I forgot to say that i do not have a provider. i need an provider finally, i have emailFrom Subject and Message, and need send this email how?
setAuthentication()call. If the SMTP server requires authentication you must provide it. If you are testing you can use a mock SMTP server, or set up your own real SMTP server and configure it without authentication.