Attempting to send mail via Java on a new mailinabox install

I am currently getting PKIX path building failed:

another exception is:

unable to find valid certification path to requested target

Here is my java code if this helps.

`	def send(toAddress, fromAddress, subject, emailBody){

	final String username = applicationService.getMailUsername();
	final String password = applicationService.getMailPassword()

	Properties props = new Properties();
	def auth        = applicationService.getMailAuth()
	def starttls    = applicationService.getMailStartTlsEnabled()
	def host        = applicationService.getMailHost()
	def port        = applicationService.getMailPort()
	props.put("mail.smtp.auth",            auth);
	props.put("mail.smtp.starttls.enable", starttls);
	props.put("",            host);
	props.put("mail.smtp.port",            port);

	println "to : ${toAddress} -> from : ${fromAddress} -> auth : ${auth} -> starttls : ${starttls} -> host : ${host} -> port : ${port}"
	Session session = Session.getInstance(props,
	  	new Authenticator() {
			protected PasswordAuthentication getPasswordAuthentication() {
				return new PasswordAuthentication(username, password);

	try {

		Message message = new MimeMessage(session);
		message.setFrom(new InternetAddress(fromAddress));
		message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(toAddress));
		message.setText(emailBody, "utf-8", "html");
	} catch (MessagingException e) {
		throw new RuntimeException(e);


What am I missing?

I am new to setting up mail servers and how to configure and use. Any additional information is much appreciated.

I was able to resolve. I needed to make sure there was an mx record.

Thank you.

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