@Jason We use Python to send emails from the end-point:
The Python Standard Library: 20.1.8. email: Examples.
#!/usr/bin/python
####################################################################################################
#
# ABOUT
#
# Script to send plain-text email:
# * Parameter 4: recipient
# * Parameter 5: subject
# * Parameter 6: message
#
####################################################################################################
#
# HISTORY
#
# Version 1.0, 7-Dec-2015, Dan K. Snelson
#
####################################################################################################
# Import commands
import commands, os, sys, smtplib, email
from email import encoders
SMTP_SERVER = 'smtp.company.com'
SMTP_PORT = 25
SMTP_FROM = 'noreply@company.com' # Must be a complete email address
SMTP_TO = str(sys.argv[4]) # Parameter 4: recipient
SUBJECT = str(sys.argv[3]) + ", " + str(sys.argv[2]) + ": " + str(sys.argv[5]) # Parameter 5: subject
MESSAGE = str(sys.argv[6]) # Parameter 6: message
msg = email.MIMEMultipart.MIMEMultipart()
body = email.MIMEText.MIMEText(MESSAGE)
msg.attach(body)
msg.add_header('From', SMTP_FROM)
msg.add_header('To', SMTP_TO)
msg.add_header('Subject', SUBJECT)
# Now send the message
mailer = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
mailer.sendmail(SMTP_FROM, [SMTP_TO], msg.as_string())
mailer.close()
The old Unix mail
command seems to work well most of the time. The syntax to do this is something like the following
echo "Message goes here" | mail -s "Subject goes here" <email_recipient>
If the above gets sent as the user, the account it's coming from usually shows up as the computer or host name, I believe. if sent via root, it shows up as "System Administrator" in my experience.
There are more advanced ways of sending mail than the above, and even some python methods to get attachments into the email, something that's really hard, maybe even impossible to do with the regular unix mail command. But if all you need is a simple email sent with subject and message, the above should work.
Caveat: I have not tried the above in High Sierra, so I don't know if something changed in that OS to make this no longer work. It wouldn't surprise me, but hopefully that hasn't been killed in it.
The old Unix mail
command seems to work well most of the time. The syntax to do this is something like the following
echo "Message goes here" | mail -s "Subject goes here" <email_recipient>
If the above gets sent as the user, the account it's coming from usually shows up as the computer or host name, I believe. if sent via root, it shows up as "System Administrator" in my experience.
There are more advanced ways of sending mail than the above, and even some python methods to get attachments into the email, something that's really hard, maybe even impossible to do with the regular unix mail command. But if all you need is a simple email sent with subject and message, the above should work.
Caveat: I have not tried the above in High Sierra, so I don't know if something changed in that OS to make this no longer work. It wouldn't surprise me, but hopefully that hasn't been killed in it.
Can you confirm this still works? I was working on a process to email notify as well s display notify the end user when the battery is faulty within the MacBook they are using, so that IT support can respond and potentially have the battery replaced while warranty is still detected.