Digital Note

Grab a coffe, take a seat, maybe listen to some music and relax by reading our digital daily diary. We want to share our minds and know how with you and the whole world!

Blog phones

PHP sendmail using gmail in Linux (LAMPP)

Masih mengacu pada tulisan saya yang sejenis disini . Tetapi sekarang saya akan beritahukan caranya jika menggunakan linux ubuntu (untuk distro lain menyesuaikan saja)

Pada tutorial ini akan menjelaskan sendmail menjadi relay email untuk akun gmail anda.

Install Sendmail

apt-get install sendmail

Membuat Gmail auth file

cd /etc/mail
mkdir /etc/mail/auth
cd /etc/mail/auth
nano /etc/mail/auth/client-info

Isi tulisan dengan format berikut:

AuthInfo:smtp.gmail.com "U:root" "I:[username]@gmail.com" "P:[passwordgmail]" "M:PLAIN"
AuthInfo:smtp.gmail.com:587 "U:root" "I:[username]@gmail.com" "P:[passwordgmail]" "M:PLAIN"

Membuat hashmap sesuai auth yang telah dibuat

cd /etc/mail/auth
makemap -r hash client-info.db < client-info

Membuat konfigurasi sendmail

cd /etc/mail/
nano /etc/mail/sendmail.mc

isikan tulisan berikut sebelum MAILER. warning!! anda perlu memperhatikan tanda quote yang digunakan ya.. karena ada quote tipis dan single quote.

#
FEATURE(`authinfo',`hash /etc/mail/auth/client-info.db')dnl
define(`SMART_HOST',`smtp.gmail.com')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')
define(`ESMTP_MAILER_ARGS', `TCP $h 587')

define(`CERT_DIR', `/etc/mail/certs')
define(`confCACERT_PATH', `CERT_DIR')
define(`confCACERT', `CERT_DIR/ca-bundle.crt')
define(`confCRL', `CERT_DIR/ca-bundle.crt')
define(`confSERVER_CERT', `CERT_DIR/sendmail.pem')
define(`confSERVER_KEY', `CERT_DIR/sendmail.pem')
define(`confCLIENT_CERT', `CERT_DIR/sendmail.pem')
define(`confCLIENT_KEY', `CERT_DIR/sendmail.pem')

define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')
#
m4 sendmail.mc > sendmail.cf
/etc/init.d/sendmail restart

Test hasil Konfigurasi

echo "Just testing my sendmail gmail relay" | sendmail -s "Sendmail gmail Relay" yourmail@domain.com

 

Semoga membantu.

Trackback from your site.

Leave a comment