Configuring vCenter for email with SMTP authentication

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.

Preparation.

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.

hMailServer Installation

Execute hMailServer-5.3.3-B1879.exe on the vCenter server.

Next

Check I Accept the agreement and Next

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.

Next

Install

Enter a password for the hMailServer Admin user.

Finish

Place a Check at Automatically connect on start-up and Connect.

Enter the admin password

The installation of hMailServer has been finished.

Configure hMailServer

Go to Settings, Protocols. We do not need POP3 or IMAP, so remove the checks. Save yor changes.

In case you forget to save changes, hMailServer will remind you and shows this message:

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 vcenter@virtual.local. 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.

23 thoughts on “Configuring vCenter for email with SMTP authentication

  1. elder geek 20/06/2011 / 20:46

    Interesting solution.. I have used Blat and Stunnel for years to solve the same problem.

  2. Dan 04/07/2011 / 15:33

    Thanks so much for this!

  3. ro 14/01/2012 / 03:50

    sorry how can i get the smtp for it

    • paulgrevink 14/01/2012 / 09:53

      Thanks for the reply. Can you please be a bit more specific concerning your question, so I can answer it.

      Regards,

      Paul

  4. mja@infomedia-fr.com 14/03/2012 / 17:30

    For me it’s ok, but I have one little problem, my ISP looks for the domain sender and my local domain doesn’t exist in real life !
    Michel

    • paulgrevink 14/03/2012 / 17:54

      Hello Michel,

      Have you tried using a Gmail account (gmail is for free)? Gmail has a lot of options, including forwarding email (to your regular account at Infomedia).

      Regards,

      Paul

  5. David Christie 01/07/2012 / 01:16

    I shall look into vCentre and see if I can set it up. Many thanks

  6. Jeff 01/09/2012 / 15:15

    Very handy screenshots and very succinctly step-by-step coverage. Worked the first time and my vCenter Server now sending SMTP messages perfectly. This is exactly what I needed for my home test lab. Thanks!

    • paulgrevink 02/09/2012 / 00:21

      Hi Jeff,

      Thanks for your feedback. Glad to know this post was helpful.

      Regards,
      Paul

  7. paopaomj 31/12/2012 / 10:26

    Hi, Paul,

    Thanks for this guide, but why “for some reasons smtp.virtual.local is not accepted”?

    Thank you.

    • paulgrevink 31/12/2012 / 14:05

      Hello,

      Thanks for the feedback. As far as I remember (I do not have the configuration available at this moment):
      DNS entry smtp.virtual.local points to “external” IP address of the vCenter server. I would have expect this address to work, but it did not. Localhost points to the loopback address and does work.

      Best regards,

      Paul

      • paopaomj 04/01/2013 / 09:02

        Hi, Paul
        Thanks for your reply.
        What about “accounts” under domains of hmailserver settings, accounts to be set here are just hmailserver accounts or domain users?
        sorry for my pool english, I’m in China.
        Thanks again.

      • paulgrevink 05/01/2013 / 13:05

        After adding a domain to the config of hMailserver, you can start adding accounts.
        Accounts are local to the hMailserver, but you will notice a tab “Active Directory”.
        This gives you the ability to connect the account to an Active Directory.
        When a user connects to hMailserver, the account will be validated against the Active Directory.
        I hope this will answer your question.

        Best regards,

        Paul

      • paopaomj 11/01/2013 / 10:10

        Thanks.
        So, because of vCenter mail setting has no authentication options, so I just need to add a blank password user account of hmailserver, right?

      • paulgrevink 11/01/2013 / 18:03

        You only need to set a password for the hMailServer Admin user. There is no need to set a blank password here.
        I hope this answers your question.

        Best regards,

        Paul

  8. Binayak 26/02/2013 / 18:28

    Yes this one really works

  9. Nitin 25/06/2013 / 22:47

    Worked like a charm. For those using pfSense as DNS, enter the following under DNS Forwarder Advanced options to be able to do MX lookup.
    “mx-host=virtual.local,mail.virtual.local,10”

    • paulgrevink 25/06/2013 / 23:00

      Hi Nitin,

      Thank you very much for your useful comment.

      Best Regards,

      Paul

  10. Derrick 11/10/2013 / 12:43

    I have went through all of the steps above and I am still having trouble getting alerts to successfully send to an external email.

    I have tried both smtp.gmail.com and my ISP’s SMTP server but for some reason it looks like from with the logs say it cant send the emails because it cant verify the FROM address.

    I set mine up in a very similar way, where the from address is alerts@mydomain.local.

    Has anyone else noticed that in the hmailserver logs the from address is different than the one you set in vCenter server mail settings?

    Any help would be greatly appreciated, Ive spent endless hours trying to get this to work and still no luck.

  11. Sanithanand Valiyapurayil 22/01/2015 / 10:05

    Hi ,

    I have 8 hosts and 1 vcenter appliance in my environment and above 50+ vms , i have one doubt anything needed to edit vcenter appliance , if anyone done in their production environment please guide me

  12. Krzysztof Baran 12/02/2016 / 13:33

    also You can use easy to configure smtp relay on Windows 2008/2012 etc
    very simply smtp server.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.