Write a test which relies on an existing mail server to check that your code can access it. This code should do the proper setup (i.e. it should send itself a mail). Guard this test with some global variable or System.property
so you can enable/disable it at runtime.
Move the code to access the server into an isolated class.
Override this class in your tests. In the test, just check that the mail text is correct. If you get a bug report that accessing the server is broken, enable the "access the real server test" and check.