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@localhostyyyy-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=queuedyyyy-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
VMware vSphere 7.x
VMware vSphere 8.x
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.
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.
Connect to vCenter Server Appliance via SSH.
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)
Alter the After entry under the [Unit] section to be as follows:
[Unit]
:
After=syslog.target network.target systemd-resolved.service
Save the changes and close the editor.
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)
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.
Save the change and close the editor.
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)
Add the following line at the end of the define entries:
define(\confDIRECT_SUBMISSION_MODIFIERS', `C')dnl`
Save the change and close the editor.
Verify that the local hostname is present and is resolvable in the hosts file: /etc/hosts (on vCenter Server)
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
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]