Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Commands & Shells

Configure Postfix to Use Gmail for Sending

Submitted by on May 16, 2012 – 12:52 pm 6 Comments

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.

#!/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} <> /etc/postfix/sender_dependent_relayhost <> /etc/postfix/tls_per_site <> ${SASL} <> ${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

 

Print Friendly, PDF & Email

6 Comments »

  • johnkaiser 22 says:

    Hi, i want to switch from yahoo to gmail but i have too many contacts and emails in yahoo and it would be very very difficult switching. Is there any way i can configure my emails so that everything that is sent to my yahoo account will automatically send to my gmail?

  • D3ZZY says:

    I have a yahoo and gmail account. I can get yahoo mail on my phone but not gmail, is there a way I can have it send messages that go to my gmail inbox sent also to my yahho account?

  • kevindiking67verizonnet says:

    I made somebody mad obviously, and somehow they shut down my gmail. I hate Google anyway, but honestly, I can’t think of anything they object to. It has to be personal, somebody that doesn’t like me, told Google to shut down my email. I need my email addresses. Anybody have any bright ideas?

  • Picean says:

    In gmail, I know it is possible to forward anything you receive to another email account automatically. However, I want gmail to automatically forward anything I receive to two email accounts…
    Is this possible, and if so, how would it be done?

  • Michael says:

    I know that somehow I had my gmail forwarded to my yahoo account, but it’s out of control. I had over 5,000 messages. I want to stop forwarding my gmail to my yahoo account, but I can’t remember how I set it up to begin with.

  • nmlpc says:

    I must of logged into my gmail account one time on my phone, and even after logging out I keep on getting notifications on my phone every time I get an email from my gmail account. How do I stop this?

Leave a Reply

%d bloggers like this: