I'm using Liferay 6.1.20 and my Portlet is using the Liferay Mail Service to send an E-Mail via the in Liferay configured SMTP-Server.

My Question is now: is it possible to check whether the SMTP-Server is available or is it possbile to check whether the E-Mail was successfully sent? If the SMTP-Server is not available I want to give an output to the User. Actually I only see the following line in the server console:

```
14:06:47,679 WARN  [liferay/mail-1][MailEngine:560] Failed to connect to a valid mail server. Please make sure one is properly configured. Could not connect to SMTP host: localhost, port: 25

```

I hope someone can give me a solution for that. Thanks!
['https://Stackoverflow.com/questions/18897410', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2343286/']
Since Liferay 6.2, if you set *mail.throws.exception.on.failure=true* in your portal-ext.properties file, the MailEngine class will also throw a `com.liferay.util.mail.MailEngineException` on errors, instead of just logging.
A really old question, but as I kept arriving here, I am leaving this to anyone that may need (tested on 7.3).

We can test if the mail flow is normal with the following Groovy script:

```
import com.liferay.mail.kernel.service.MailServiceUtil
import javax.mail.*
import javax.mail.internet.*
import com.liferay.mail.kernel.model.MailMessage;

def from = new InternetAddress("no-reply@example.com")
def to = new InternetAddress ("where@example.com")
def mail = new MailMessage(from, to, "subject", "test message", false)
MailServiceUtil.sendEmail(mail)

```

And, as mentioned in the other answer, the property to view exceptions is still valid.

```
mail.throws.exception.on.failure=true

```