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(“mail.smtp.host”, “smtp.gmail.com”); //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 box.profitabit.club

possibly it is not smtp.box.profitabit.club


Do you have any guidance I would be grateful.

Thank you.

SMTP just runs under the same hostname, in your case box.profitabit.club. 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=“box.profitabit.club”;
final String user=“xxx@xxx.xxx”;//change accordingly
final String password=“xxxx”;//change accordingly

String to="vvv@vvv.com";//change accordingly

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

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

Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user,password);
}
});
session.setDebug(true);
//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
Transport.send(message);

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

} catch (MessagingException e) {
e.printStackTrace();
}

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