[sourcecode] #!/bin/bash # Function for sending email function sendemail(){ boundary=$(</dev/urandom tr -dc A-Za-z0-9 | head -c8 | base64) to_email_addresslist="" ( echo open $SMTP_DOMAIN $SMTP_PORT sleep 8 echo helo $SMTP_DOMAIN echo mail from: $MAIL_SENDER_ADDRESS sleep 2 for to_mail in $MAIL_RECIPIENT_ADDRESS do echo rcpt to: $to_mail to_email_addresslist="$to_email_addresslist<$to_mail>;" sleep 2 done echo data sleep 2 echo to: $to_email_addresslist sleep 2 echo from: $MAIL_SENDER_ADDRESS sleep 2 echo subject: $MAIL_SUBJECT echo "MIME-Version: 1.0" echo 'Content-Type: multipart/mixed; boundary="'$boundary'"' echo echo '--'$boundary echo 'Content-Type: text/html; charset=utf-8' echo $1 if [ "$#" -ge 2 ] then echo echo '--'$boundary echo 'Content-Type: text/plain; name="'$(basename $2)'"' echo "Content-Transfer-Encoding: base64" echo 'Content-Disposition: attachment; filename="'$(basename $2)'"' base64 $2 fi echo '--'$boundary'--' echo echo sleep 5 echo . sleep 5 echo sleep 2 echo quit ) | telnet if [ $? -eq 0 ] then echo "Notification email sent to ${MAIL_RECIPIENT_ADDRESS}." >> $logfilename else echo "Failed to sent Notification email to ${MAIL_RECIPIENT_ADDRESS}." >> $logfilename fi } sendemail "email body message text goes here" "fullfilepath" [/sourcecode]
[sourcecode]
#!/bin/bash
# Function for sending email function sendemail(){ boundary=$(</dev/urandom tr -dc A-Za-z0-9 | head -c8 | base64) to_email_addresslist="" ( echo open $SMTP_DOMAIN $SMTP_PORT sleep 8 echo helo $SMTP_DOMAIN echo mail from: $MAIL_SENDER_ADDRESS sleep 2 for to_mail in $MAIL_RECIPIENT_ADDRESS do echo rcpt to: $to_mail to_email_addresslist="$to_email_addresslist<$to_mail>;" sleep 2 done echo data sleep 2 echo to: $to_email_addresslist sleep 2 echo from: $MAIL_SENDER_ADDRESS sleep 2 echo subject: $MAIL_SUBJECT echo "MIME-Version: 1.0" echo 'Content-Type: multipart/mixed; boundary="'$boundary'"' echo echo '--'$boundary echo 'Content-Type: text/html; charset=utf-8' echo $1 if [ "$#" -ge 2 ] then echo echo '--'$boundary echo 'Content-Type: text/plain; name="'$(basename $2)'"' echo "Content-Transfer-Encoding: base64" echo 'Content-Disposition: attachment; filename="'$(basename $2)'"' base64 $2 fi echo '--'$boundary'--' echo echo sleep 5 echo . sleep 5 echo sleep 2 echo quit ) | telnet if [ $? -eq 0 ] then echo "Notification email sent to ${MAIL_RECIPIENT_ADDRESS}." >> $logfilename else echo "Failed to sent Notification email to ${MAIL_RECIPIENT_ADDRESS}." >> $logfilename fi }
sendemail "email body message text goes here" "fullfilepath"
[/sourcecode]
Hope the above can help you