Sending email by crontab and sendmail

1. /home/www/mailq/sendmail.sh

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

#!/bin/bash

user='kim';
subject='hello kim';
content='this is just a test email.';
from='kim@example.com';
to='xqpmjh@gmail.com';

echo $content | formail -I "To: $to" -I "From: $from" -I "MIME-Version:1.0" -I "Content-type:text/html;charset=utf-8" -I "Subject:=?UTF-8?B?`echo $subject | openssl enc -base64`?=" | /usr/sbin/sendmail -oi $email;

[/codesyntax]


2. crontab

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ crontab -u root -e

[/codesyntax]

* * * * * cd /home/www/mailq; source sendmail.sh;

Posted in Linux | Tagged , | Leave a comment