Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts
in

Cara mengirim email GMAIL dengan menggunakan sSMTP

- - No comments
ini configurasi di uBuntu
Install command/bila belum install :
apt-get install ssmtp
 
kemudian edit konfigurasi di ssmtp.conf
vi /etc/ssmtp/ssmtp.conf

Edit/paste bagian ini : 
root=username@gmail.com
mailhub=smtp.gmail.com:587
rewriteDomain=
hostname=username@gmail.com
UseSTARTTLS=YES
AuthUser=username
AuthPass=password
FromLineOverride=YES

Edit juga bagian revaliases
/etc/ssmtp/revaliases

Edit/paste bagian ini :
root:username@gmail.com:smtp.gmail.com:587
youruser:username@gmail.com:smtp.gmail.com:587
 
Konfigurasi selesai anda bisa menggunakan command di bawah ini untuk test email,

# ssmtp user@domain.com
Subject: This is Subject Line
Email content line 1
Email content line 2
Email content line 3
^d

untuk memastikan lagi silakan juga liat di log /var/log/maillog.
--------------


sedikit berbeda di RHEL tambahkan TLS sesuai yang di garis merah

# Use SSL/TLS to send secure messages to server.
UseTLS=YES

root=xxx.xxx@gmail.com
mailhub=smtp.gmail.com:587
rewriteDomain=
hostname=xxx.xxx@gmail.com
UseSTARTTLS=YES
AuthUser=xxx.xxx
AuthPass=xxxxx
FromLineOverride=YES

TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt

Edit juga bagian revaliases
/etc/ssmtp/revaliases

Edit/paste bagian ini :
root:username@gmail.com:smtp.gmail.com:587
youruser:username@gmail.com:smtp.gmail.com:587

Install EPEL repository to install sSMTP.
rpm -Uvh ftp://ftp.univie.ac.at/systems/linux/fedora/epel/5/i386/epel-release-5-4.noarch.rpm

Change MTA and choose ssmtp
alternatives --config mta


Note :
sSMTP source : ftp://ftp.univie.ac.at/systems/linux/fedora/epel/5/x86_64/ssmtp-2.61-21.el5.x86_64.rpm
http://unix.stackexchange.com/questions/109473/after-updating-ssmtp-to-version-2-61-i-cannot-send-mail-via-gmail
http://forums.fedoraforum.org/showthread.php?p=1674889
https://bugzilla.redhat.com/show_bug.cgi?id=1004998


in

autosendmail script di linux

- - No comments
 Curl dan wget installed
 
Try#1:

#!/bin/sh

now=$(date +'%m/%d/%Y %T'); 
#default values
sendto="anam.akhmad@gmail.com"
subject="[automail]IP Notification "${now}""
from="Paman Gober"
errorsfile=/tmp/ssmtp.error

getIP=$(wget http://ipecho.net/plain -O - -q ; echo);
#getIP2=curl ipecho.net/plain; echo
#getIP3=curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
#getIP4=curl icanhazip.com

header="Subject: ${subject}\nFrom:${from}\nTo:${sendto}\n"
content="Info dari gober\n\nIP server saat ini ${getIP}\nPeringatan!!.Setelah menerima pesan ini mohon di hapus segera dari email anda \n\nSalam dari Gober"

# workaround for the 'sh echo' not handling -e
if [ -n "$(/bin/sh -c 'echo -ne')" ]; then
  echocmd=echo
else
  echocmd=echo\ -e
fi

$echocmd "${header}${content}" | ssmtp "${sendto}" 2>>${errorsfile}
exit $?