Thursday, 23 July 2015

Send email with attachment from openwrt

install ssmtp
configure ssmtp

edit /etc/ssmtp/ssmtp.conf


root=youremail@hotmail.com
mailhub=smtp.live.com:587

# Where will the mail seem to come from?
rewriteDomain=makesomethingup

# The full hostname
hostname=localhost

# Set this to never rewrite the "From:" line (unless not given) and to
# use that address in the "from line" of the envelope.
FromLineOverride=YES

# Use SSL/TLS to send secure messages to server.
UseTLS=YES
UseSTARTTLS=YES
AuthUser=youremail@hotmail.com
AuthPass=youremailpassword
-----------------------------------------------------------------------------------------------------------------------
install mutt
install terminfo
configure mutt

edit /etc/Muttrc

mailboxes /tmp/mail
set sendmail="/usr/sbin/ssmtp"
set from="youremail"
set realname="yourname"
# Mail folder setup.
set folder=/tmp/mail
set mbox_type=mbox
set spoolfile=+inbox
set mbox=+received
set postponed=+postponed
set record=+sent

send test attachment
echo "test" | mutt -s "my_first_test" toaddress@zyx.com -a /www/CameraImages/photo.jpg

get newest filename
ls -t /www/CameraImages | head -n 1

I wanted to send the newest image in a folder-
send newest file as attachment
echo "test" | mutt -s "my_first_test" toaddress@hotmail.com -a /www/CameraImages/$(ls -t /www/CameraImages | head -n 1)