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.

Advertisements

23 Responses to Configuring vCenter for email with SMTP authentication

  1. elder geek says:

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

  2. Dan says:

    Thanks so much for this!

  3. […] resaltar que este post está basado en un post de Paul Grevink, del cual he podido recoger la mayoría de los recursos de este post. Finalmente le he dado algún […]

  4. ro says:

    sorry how can i get the smtp for it

  5. mja@infomedia-fr.com says:

    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 says:

      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

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

  7. […] resaltar que este post está basado en un post de Paul Grevink, del cual he podido recoger la mayoría de los recursos de este post. Finalmente le he dado algún […]

  8. Jeff says:

    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!

  9. paopaomj says:

    Hi, Paul,

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

    Thank you.

    • paulgrevink says:

      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 says:

        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 says:

        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 says:

        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 says:

        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

  10. Binayak says:

    Yes this one really works

  11. Nitin says:

    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”

  12. Derrick says:

    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.

  13. Sanithanand Valiyapurayil says:

    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

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: