When writing the “Checking the diskspace on your VMFS volumes” blog I assumed that most of you knew how to send an email from the service console. I received a bunch of emails from people who were interested in how to setup the html email functionality. Well, here it is:
A while back VMGuru.com hosted a script which enabled you to send email from the service console. I just browsed their site and it’s nowhere to be found. So I hosted it on my site, mind: I changed the script so that you are able to send HTML emails. This is very useful for the vdfhtml script, that’s the name I gave it… You can download the new smtp_send.pl here. All credits for smtp_send.pl go to Scott Herold and Jeremy Pries. I only changed the following:
$msg->attach(Type =>’TEXT’,
became
$msg->attach(Type =>’TEXT/HTML’,
Upload this script to /usr/local/bin, and upload Lite.pm from the MIME package to /usr/lib/perl5/5.8.0/MIME/, the “5.8.0″ directory could be different on your ESX build, it depends on which version of perl is running. Now open up the firewall for smtp out to be able to send email:
esxcfg-firewall -o 25,tcp,out,SMTP
Now you can send html email with the following command, in this example I used the vdf.html ouput file as input for the body of the email.
/usr/local/bin/smtp_send.pl -t info@test.com -s “Diskspace report of the VMFS volumes” -f esx01@test.com -m “`cat /var/log/vdf.html`” -r 172.10.10.10
-t = Receiver
-s = Subject
-f = Sender
-m = Message body
-r = Mail relay host
You can add this line to the bottom of the vdf-vmfs script and schedule this script via the crontab. Add the following line(I assumed you named the script vdfhtml.sh) to the crontab if you want to receive this email every day at 10:00:
00 10 * * * root /usr/local/bin/vdfhtml.sh





Thanks for posting this. I’m glad to know that I’m not the only person that didn’t know how to do this!