Configure Postfix to Use Gmail for Sending
Here is a simple script to help you configure Linux postfix to use your Gmail account for sending emails. The script has been tested on OpenSuse 11.4 and 12.1, but should work find on any recent Linux disro. The only requirement is that you have postfix insalled.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
#!/bin/bash # igor@krazyworks.com # 2012-05-16 # # Configure Postfix to use your Gmail account for sending emails. # Tested on OpenSuse 11.4 & 12.1 configure () { if [ `rpm -qa | grep -ic postfix` -lt 1 ] then echo "Postfix is not installed. Exiting..." exit 1 fi POSTCONF=/etc/sysconfig/postfix MAINCF=/etc/postfix/main.cf SASL=/etc/postfix/sasl_passwd read -p "Enter your Gmail address " gmail_address read -s -p "Enter your Gmail password: " gmail_password } postconf() { if [ -f ${POSTCONF} ] then cat >> ${POSTCONF} << EOF POSTFIX_ADD_SENDER_DEPENDENT_RELAYHOST_MAPS="hash:/etc/postfix/sender_dependent_relayhost" POSTFIX_ADD_SMTP_TLS_PER_SITE="hash:/etc/postfix/tls_per_site" EOF fi cat >> /etc/postfix/sender_dependent_relayhost << EOF ${gmail_address} [smtp.gmail.com]:587 EOF cat >> /etc/postfix/tls_per_site << EOF smtp.gmail.com MUST EOF if [ `grep -c ${gmail_address} ${SASL}` -lt 1 ] then cat >> ${SASL} << EOF gmail.com ${gmail_address}:${gmail_password} EOF else echo "Account ${gmail_address} is already listed in ${SASL}" fi if [ `grep -c "smtp_tls_CApath = /etc/ssl/certs" ${MAINCF}` -lt 1 ] then cat >> ${MAINCF} << EOF smtp_tls_CApath = /etc/ssl/certs EOF fi c_rehash /etc/ssl/certs /etc/init.d/postfix stop /etc/init.d/postfix start } # RUNTIME configure postconf |
-
johnkaiser 22
-
D3ZZY
-
kevindiking67verizonnet
-
Picean
-
Michael
-
nmlpc
