Java smtp send mail programmaticly

Hi guys I manage to set up the server. Now I am trying to send mail programmatically using JAVA. I am using this link:

I am doing this operation
Send Email in Java SMTP with TLS Authentication

props.put(“”, “”); //SMTP Host
props.put(“mail.smtp.port”, “587”); //TLS Port this parts what is the smtp link…

What is the smtp for the box.
My mail is

possibly it is not

Do you have any guidance I would be grateful.

Thank you.

SMTP just runs under the same hostname, in your case The port is correct. The username is your full email address.

You also need to make sure that the envelope sender (From:) is explicitly set, and that this matches the exact email address you used to login (or any associated aliases), otherwise your program seems successful, but postfix will queue the message and drop it right afterwards, so no email will get through.

This is the code it works: Thanks for the support

String host=“”;
final String user=“”;//change accordingly
final String password=“xxxx”;//change accordingly

String to="";//change accordingly

//Get the session object
Properties props = new Properties();
props.put(“mail.smtp.auth”, “true”);
props.put(“mail.smtp.starttls.enable”, “true”);
props.put(“”, “”);
props.put(“mail.smtp.port”, “587”);

MailSSLSocketFactory sf = null;
try {
sf = new MailSSLSocketFactory();
} catch (GeneralSecurityException e) {
props.put(“”, “*”);
props.put(“mail.smtp.ssl.socketFactory”, sf);

Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user,password);
//Compose the message
try {
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(user));
message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
message.setSubject(“ProfitAbit Welcomes you.”);
message.setText(“We at last manage to send you request. I hope you will enjoy our service and our platform.”);

//send the message

out.println("message sent successfully...");

} catch (MessagingException e) {

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.