alan6854321
Senior Member
I have a script that sends me an Email on WAN connected (via the wan-event script).
On loading the latest Merlin release, the Email is rejected by my ISP as the date/time in the header is the "05 May" the router has before it connects to ntp (I don't think this has anything to do with the latest release, it's the first reload for about 70 days).
The Email gets delivered fine if I reset the WAN connection later on, and according to the entry in syslog, the failing Email is sent when the time has already been set.
The method I use to send the Email I stole from a thread on here somewhere (I'm not a great script expert), this is a snippet where the Email is sent (it uses parameters set in amtm). The "Email sent" message appears in syslog with a valid date/time.
So.. how does the date/time in the Email header get set?
The wan-event script has the following, I think it waits for ntp to be set ..
On loading the latest Merlin release, the Email is rejected by my ISP as the date/time in the header is the "05 May" the router has before it connects to ntp (I don't think this has anything to do with the latest release, it's the first reload for about 70 days).
The Email gets delivered fine if I reset the WAN connection later on, and according to the entry in syslog, the failing Email is sent when the time has already been set.
The method I use to send the Email I stole from a thread on here somewhere (I'm not a great script expert), this is a snippet where the Email is sent (it uses parameters set in amtm). The "Email sent" message appears in syslog with a valid date/time.
So.. how does the date/time in the Email header get set?
Code:
# ---- OK - lets send it
/usr/sbin/curl -v --url ${PROTOCOL}://${SMTP}:${PORT} \
--mail-from "$FROM_ADDRESS" --mail-rcpt "$TO_ADDRESS" \
--user "${USERNAME}:$(/usr/sbin/openssl aes-256-cbc "$emailPwEnc" -d -in "$amtmEMailPswdFile" -pass pass:ditbabot,isoi)" \
--upload-file "$cemTempEMailContent" \
$SSL_FLAG --ssl-reqd --crlf >> "$cemTempEMailLogFile" 2>&1
if [ $? -eq 0 ]
then
rm -f "$cemTempEMailLogFile"
rm -f "$cemTempEMailContent"
logger Email sent: $1
else
logger Email: FAILED to send, see $cemTempEMailLogFile
fi
The wan-event script has the following, I think it waits for ntp to be set ..
Code:
#!/bin/sh
#
# Send Email when the WAN is restored,
# Wait for network to come up first.
#
if [[ $# -gt 1 ]] && [[ $2 == "connected" ]]
then
ntpclient -h pool.ntp.org -s &> /dev/null
sleep 5
/jffs/AGT/scripts/send-wan-connected-email &
fi
Last edited: