Sunday, May 18, 2014

Setting up basic mail server with gmail account on debian

Sending mail via Gmail from ssmtp on debian !!!



ssh ${server}
su

# aptitude install sendmail
aptitude install ssmtp

vi /etc/ssmtp/ssmtp.conf
--------------------------
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=xxxx@gmail.com

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
#mailhub=mail
mailhub=smtp.gmail.com:587

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

# The full hostname
hostname=myHostName

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES

AuthUser=xxxx
AuthPass=xxxx
UseSTARTTLS=YES
#UseTLS=YES
--------------------------

tail -f /var/log/mail.log
--------------------------
May 19 07:06:11 Lenovo-PC sSMTP[9764]: Creating SSL connection to host
May 19 07:06:12 Lenovo-PC sSMTP[9764]: SSL connection using RSA_ARCFOUR_SHA1
May 19 07:06:15 Lenovo-PC sSMTP[9764]: Sent mail for root@xxxx (221 2.0.0 closing connection zv3sm61423449pab.20 - gsmtp) uid=0 username=root outbytes=494

--------------------------

echo "Test Mail" | mail -s "Test" "xxxx@gmail.com"


######## extra settings ########

vi /etc/ssmtp/revaliases
--------------------------
# sSMTP aliases
#
# Format: local_account:outgoing_address:mailhub
#
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.
root:xxx@gmail.com:smtp.gmail.com:587
anyUser:xxx@gmail.com:smtp.gmail.com:587
--------------------------

No comments:

Post a Comment