Fail to Send SMTP Alerts from the vCenter Server
search cancel

Fail to Send SMTP Alerts from the vCenter Server

book

Article ID: 414955

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

  • Emails are not being sent from the vCenter Server Appliance when an alert or event is triggered.

  • Following logs can be seen in /var/log/vmware/messages

yyyy-mm-ddThh:mm:ss.616506+00:00 hostname sendmail[1987489]: 59D7F2wk1987489: from=root, size=165, class=0, nrcpts=1, msgid=<[email protected]>, relay=root@localhost
yyyy-mm-ddThh:mm:ss.616641+00:00 hostname sendmail[1987489]: 59D7F2wk1987489: [email protected], delay=00:00:00, mailer=esmtp, pri=30165, dsn=4.4.3, stat=queued
yyyy-mm-ddThh:mm:ss.829066+00:00 hostname sudo:     vpxd : PWD=/storage/log/vmware/vpxd ; USER=root ; COMMAND=/bin/sudo_command_wrapper.sh /usr/sbin/sendmail -tf [email protected]
yyyy-mm-ddThh:mm:ss.037604+00:00 hostname sendmail[2760187]: 59DNQZdG2760187: [email protected], delay=00:00:01, mailer=esmtp, pri=31035, dsn=4.4.3, stat=queued

 

Environment

VMware vSphere 7.x

VMware vSphere 8.x

Cause

The issue is caused by a misconfiguration in the DNS settings, specifically the absence of MX (Mail Exchanger) records for the mail server. This prevents the vCenter Server Appliance from identifying the correct mail server to relay emails.

Resolution

Create MX records for the mail server in the DNS server to fix the the given issue. 

OR

Please follow the workaround(on the vCenter Server)

**Please take snapshot of the vCSA VM before making the follwing changes. 

  1. Connect to vCenter Server Appliance via SSH.

  2. Edit sendmail.service using the vi editor. (Make a copy of the original file before editing it: cp /lib/systemd/system/sendmail.service /lib/systemd/system/sendmail.service.bkp)
    vi /lib/systemd/system/sendmail.service (This is for 7.0 and later versions)

  3. Alter the After entry under the [Unit] section to be as follows:
    [Unit]
    :
    After=syslog.target network.target systemd-resolved.service

  4. Save the changes and close the editor.

  5. Open sendmail.mc using the vi editor: /etc/mail/sendmail.mc  (Make a copy of the original file before editing it: cp /etc/mail/sendmail.mc /etc/mail/sendmail.mc.bkp)

  6. Add the following entry after OSTYPE:
    FEATURE(\nocanonify')dnl define(`SMART_HOST', `[Your_mail_host]')dnlNote: ChangeYour_mail_host` to reflect the correct mail server hostname.

  7. Save the change and close the editor.

  8. Next, edit submit.mc using the vi editor: vi /etc/mail/submit.mc (Make a copy of the original file before editing it: cp /etc/mail/submit.mc /etc/mail/submit.mc.bkp)

  9. Add the following line at the end of the define entries:
    define(\confDIRECT_SUBMISSION_MODIFIERS', `C')dnl`

  10. Save the change and close the editor.

  11. Verify that the local hostname is present and is resolvable in the hosts file: /etc/hosts (on vCenter Server)

  12. Execute the following command and generate a new .cf file:
    cd /etc/mail
    m4 m4/cf.m4 sendmail.mc > sendmail.cf
    m4 m4/cf.m4 submit.mc > submit.cf

  13. Reload the system daemon and restart sendmail.
    systemctl daemon-reload
    systemctl restart sendmail

Check the SMTP queue and send a test email from vCSA or test by invoking any of the existing configured alarm definitions configured for sending email alerts.
sendmail -v -q
echo "Subject: sendmail test" | sendmail -v [email protected]