Thursday, May 8, 2014

Emails sending with postfix using gmail account

Send an email with postfix using gmail account


1. Add the following information to /etc/postfix/sasl_passwd file

[smtp.gmail.com]:587    your_gmail_account@gmail.com:your_gmail_password

2. Create a new script you call something like sen.sh with the following content


receiver_mail_address=$1
subject=$2
content=$3

sendmail $receiver_mail_address <<EOF
subject:$subject
Content-Type: text/html #if you want to support html content
from:your_gmail_account@gmail.com
$content
EOF

You can now send email with the following command:

$sen.sh some_receivr@domain.com "test email" "this is a test"

No comments:

Post a Comment