Send mail within bash script with SMTP AUTH
As in the title I need to send email (with log report, etc..) within a bash script executed by a cronjob.
As I set in my WHM this two things (Mod security):
- ]
- The pseudo-user "nobody" is not permitted to send email.
- Outbound SMTP connections are restricted.
#!/bin/bash
DATA=`date +%H`
FILE="/home/path/to/file/file.txt"
USER="domaincom"
DOMINIO="domain.com"
TO="myuser@domain1.it"
FROM="cpanel"
SUBJECT="email from cP"
echo "To: $TO" >> $FILE
echo "From: $FROM" >> $FILE
echo "Subject: $SUBJECT" >> $FILE
echo " " >> $FILE
cat "/home/$USER/access-logs/$DOMINIO" | grep "/2015:$DATA" >> $FILE
/usr/sbin/sendmail -t < $FILE
-
Hello, You will likely receive more input on development questions on a website such as StackOverflow. Or, you could try searching for "PHP SMTP Authentication" on a search engine for examples of how others have developed these types of scripts. Thank you. 0
Please sign in to leave a comment.
Comments
1 comment