vCenter allows you to configure Alarms to send email if required. Before vCenter can send it’s first email, go in the menu, choose Administration and vCenter Server Settings. Select the Mail section. In this section you can enter the name of the SMTP server (that will relay the email) and in Sender Account, the name of the account used to send email.
In my homelab, I did like to send email to my Gmail account. It would also be nice to use smtp.gmail.com as a mail-relay. Gmail demands authentication, unfortunately, at this moment it is not possible to configure SMTP authentication with vCenter. This is confirmed in VMware KB 1004070.
There are some options, run your own Microsoft Exchange server, or install a Linux VM and run Postfix. This is my homelab, I want a simple solution, and I do not want vCenter to be dependent on all kinds of other VMs that run database- or SMTP servers. For this reason, MS SQL is installed on the vCenter server and it would be nice to send email directly from vCenter.
So it is time to add some extra functionality, in this case: hMailServer. hMailServer is a free and easy to configure email server for Microsoft Windows, it also runs on Windows Server 2008 R2.
Here is a tutorial how to install, configure, test and troubleshoot hMailServer with vCenter.
The fqdn of my vCenter server is: vc.virtual.local.
At first, we create an alias for the SMTP server, something like: smtp.virtual.local.
Next, we create a MX-record for the zone virtual.local.
To test the result, open a DOS box and type this command:
> nslookup –type mx <zone name>
The response should be something like this.
Execute hMailServer-5.3.3-B1879.exe on the vCenter server.
Check I Accept the agreement and Next
Accept Full installation and Next
For a homelab the option Use built-in database engine (Microsoft SQL Compact) is just fine. The Microsoft SQL Server Compact Edition may not be used with commercial hosting services. Read this for alternatives.
Enter a password for the hMailServer Admin user.
Place a Check at Automatically connect on start-up and Connect.
Enter the admin password
The installation of hMailServer has been finished.
Go to Settings, Protocols. We do not need POP3 or IMAP, so remove the checks. Save yor changes.
Go to Settings, Protocols, SMTP and to the tab Delivery of e-mail.
In this example smtp.gmail.com is the relaying SMTP server.
Enter the following information:
Local host name, remember I have created an alias in my DNS.
Remote host name. In this case I want to relay to Gmail. Google requires SSL authentication. So enter the Remote host name, Remote TCP/IP port must be 465, your Gmail credentials and do not forget to check Use SSL.
Go to Settings, Advanced, IP ranges. At this moment we only want to handle email from the local server, so remove the Internet range.
Edit My Computer.
Remove all checks, except SMTP under Allow Connections and under Allow deliveries from, place a check at Local to local e-mail addresses and Local to external e-mail addresses. The last one allows to send email outside the virtual.local domain. Do not place checks under Require SMTP authentication. Save
Go to Welcome, to add a mail domain.
Enter the name of your mail domain, in my case: virtual.local and Save the changes.
Now, it is time to check you configuration. Go to Utilities, Diagnostics. Under Select the domain you want to run test on, select your new maildomain and push the Start button.
If everything goes well, you should get something like this. If not, try to figure out what went wrong.
Now it is time to configure vCenter, if you have already done this, please do read this section!
Go in the menu, choose Administration and vCenter Server Settings. Select the Mail section and enter the following information:
- at SMTP server: localhost (for some reason, smtp.virtual.local is not accepted!)
- at Sender Account: in my case firstname.lastname@example.org. The last part must match your email domain.
It is now time for the final test. Maybe, you have already configured you Alarms, so you can wait until something will happen. There is a another way to instantly test the new possibility of vCenter.
Go to Scheduled Tasks and create a New task. Actually we are going to start a VM.
Select: Change the VM power state.
Select the VM you want to start.
Choose Power on.
Enter a descriptive Task name and Start Time is Now.
Make sure Send email to the following addresses when the task is complete is checked and enter the email address(es) that should receive email.
One final window and the new task will execute.
When it does not work (troubleshooting)
- On the vCenter server, check the logging under Home, Management, Events.
- In case vCenter reports: … sent email to …
then vCenter was able to deliver email at the SMTP server.
- If everything seems to be OK on the vCenter server, than it is time to check hMailServer.
- hMailServer has several Logging options. Go to Status, tab Logging and push Start. Then go back to vCenter, start a task and watch the logging in hMailServer.
- You can also see pending email, go to tab Delivery queue and Refresh.
- hMailServer is also able to create Log files. Go to Settings, Logging. Place a check at Enabled, SMTP and Debug. Then execute the task, return to hMailServer and Show logs.
Final words. I hope this tutorial is helpful. If you have any questions, please respond. Enjoy reading.