LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-05-2011, 12:57 AM   #1
cola
Senior Member
 
Registered: Sep 2007
Distribution: Debian
Posts: 1,032

Rep: Reputation: 64
Question How would i configure/set up postfix to send email from my local pc ?


It's debian.
I have installed postfix.
Code:
aptitude install postfix bsd-mailx mailutils
During installation i selected Internet site.

This is the /etc/postfix/main.cf
Code:
# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = site1.example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = myhost.localhost.localdomain, site1.example.com, localhost.example.com, localhost
relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
The hostname = 'myhost'
Code:
cat /etc/hosts

127.0.0.1   localhost.localdomain localhost
127.0.0.1	 mysite.com  myhost

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Code:
mail -s 'subject' temp@yahoo.com
It's waiting in terminal, it looks it's doing nothing.

From /var/log/mail.log i got
Code:
Nov  4 12:56:03 site1 postfix/error[2517]: CFA837F9A5: to=<temp@yahoo.com>, relay=none, delay=29200, delays=29094/106/0/0.09, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to mta5.am0.yahoodns.net[66.94.236.34]:25: Connection timed out

Last edited by cola; 11-05-2011 at 01:00 AM.
 
Old 11-05-2011, 01:52 AM   #2
ceyx
Member
 
Registered: May 2009
Location: Fort Langley BC
Distribution: Kubuntu,Free BSD,OSX,Windows
Posts: 342

Rep: Reputation: 59
The key information in your log is this : "relay=none"

Check out my posts in this thread :

http://www.linuxquestions.org/questi...er-909631-new/

keep us posted ( pun intended ) :-)
 
Old 11-05-2011, 02:30 AM   #3
cola
Senior Member
 
Registered: Sep 2007
Distribution: Debian
Posts: 1,032

Original Poster
Rep: Reputation: 64
Quote:
Originally Posted by ceyx View Post
The key information in your log is this : "relay=none"

Check out my posts in this thread :

http://www.linuxquestions.org/questi...er-909631-new/

keep us posted ( pun intended ) :-)
What will be the value of relayhost = ?

I have tried with relayhost = gmail.com , relayhost = mail.myispinternetcompany.com but it didn't work. It didn't send any mail.
 
Old 11-05-2011, 03:01 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
Most relay hosts will require logon and will only accept mails apparently coming from a valid domain (In the "reply to" and maybe envelope address).

For Gmail you need smtp.gmail.com and port 587
 
1 members found this post helpful.
Old 11-05-2011, 05:19 AM   #5
cola
Senior Member
 
Registered: Sep 2007
Distribution: Debian
Posts: 1,032

Original Poster
Rep: Reputation: 64
Quote:
Originally Posted by catkin View Post
Most relay hosts will require logon and will only accept mails apparently coming from a valid domain (In the "reply to" and maybe envelope address).

For Gmail you need smtp.gmail.com and port 587
I tried
Code:
relayhost = smtp.gmail.com
port = 587
cat /var/log/mail.log
Code:
Nov  4 17:22:40 site1 postfix/smtp[4321]: connect to smtp.gmail.com[74.125.127.109]:25: Connection timed out
Can you post the contentes of the configuration file (main.cf) ? I have posted the default configuration above with original question.

Can you post your configuration file (main.cf) ?

Last edited by cola; 11-05-2011 at 05:22 AM.
 
Old 11-05-2011, 05:40 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
Here it is
Code:
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
append_dot_mydomain = no
readme_directory = no
smtpd_tls_CAfile = /etc/postfix/cacert.pem
smtpd_tls_cert_file = /etc/postfix/LS1-cert.pem
smtpd_tls_key_file = /etc/postfix/LS1-key.pem
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes
smtpd_use_tls = yes
myhostname = LS1.<valid, non-local domain name>
myorigin = /etc/mailname
mydestination = LS1.<valid, non-local domain name>,localhost.<valid, non-local domain name>,localhost
relayhost = [smtp.googlemail.com]:587
mynetworks = 127.0.0.0/8 192.168.3.51
inet_interfaces = all
default_transport = smtp
relay_transport = smtp
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_generic_maps = hash:/etc/postfix/generic
transport_maps = hash:/etc/postfix/transport
virtual_alias_maps = hash:/etc/postfix/virtual
Several other files have to be set up to work with that main.cf: /etc/mailname,/etc/aliases and /etc/postfix/*:
Code:
root@LS1:/etc/postfix# lrt
total 132K
drwxr-xr-x 2 root root    1 May  5  2011 sasl
-rwxr-xr-x 1 root root  24K May  5  2011 post-install
-rwxr-xr-x 1 root root 8.6K May  5  2011 postfix-script
-rw-r--r-- 1 root root  19K May  5  2011 postfix-files
-rw-r--r-- 1 root root 5.2K Oct 24 12:33 master.cf
-rw-r--r-- 1 root root  318 Oct 24 12:33 dynamicmaps.cf
-rw-r--r-- 1 root root 1.3K Oct 24 13:32 main.cf
-rw-r--r-- 1 root root   46 Oct 24 13:32 virtual
-rw-r--r-- 1 root root   74 Oct 24 13:32 transport
-r-------- 1 root root   97 Oct 24 13:32 sasl_passwd
-rw-r--r-- 1 root root   82 Oct 24 13:32 generic
-rw-r--r-- 1 root root  12K Oct 24 13:32 virtual.db
-rw-r--r-- 1 root root  12K Oct 24 13:32 generic.db
-rw-r--r-- 1 root root  12K Oct 24 13:32 sasl_passwd.db
-rw-r--r-- 1 root root  12K Oct 24 13:32 transport.db
-rw-r--r-- 1 root root 2.3K Oct 24 13:32 cacert.pem
A script I wrote to do this is at http://pastebin.com/fBMrAMRB. An example of using it:
Code:
/root/bin/configure_postfix.sh -a 'root:<valid, non-local email address>' -i '192.168.3.51' -p 'LS1.<valid non-local domain>' -r smtp.googlemail.com:587:<user name (email address) for smtp.googlemail.com>:<passsword for smtp.googlemail.com>
 
Old 11-05-2011, 05:42 AM   #7
bradleymaustin
LQ Newbie
 
Registered: Nov 2011
Location: Chandler, AZ
Distribution: Ubuntu/Fedora/Arch
Posts: 3

Rep: Reputation: Disabled
have you thought about using mozilla tunderbird?
 
Old 11-05-2011, 06:09 AM   #8
cola
Senior Member
 
Registered: Sep 2007
Distribution: Debian
Posts: 1,032

Original Poster
Rep: Reputation: 64
Quote:
Originally Posted by catkin View Post
Here it is

That pastebin link is broken.

Can you post the contents of that script ?

What is LSI ?

I don't have those .db files in /etc/postfix

Probably your settings is to send email from a gmail account.
Is it possible to send email from local pc address like , useraccount@localhost.localdomain ?

Some confusion about main.cf terminology
What are
Code:
myorigin
myhostname
mydestinations
mynetworks

Last edited by cola; 11-05-2011 at 06:31 AM.
 
Old 11-05-2011, 06:38 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
Quote:
Originally Posted by cola View Post
That pastebin link is broken.
The link might be OK; pastebin is down at the moment.
Quote:
Originally Posted by cola View Post
Can you post the contents of that script ?
Bigger than I like to post but seeing as pastebin is down:
Code:
#! /bin/bash

# Purpose: 
#    Configures postfix for sending via a relay (smart host). Suitable for
#    sending mail from a postfix server behind a NATting router.

# Usage: 
#    See usage function below (search for "function usage") or use -h option.
    
# Environment:
#    Developed and tested on Debian Squeeze with
#    * bash 4.1.5
#    * postfix 2.7.1

# History:
#    23oct11 Charles
#    * First version

# Wishlist (in approx descending order of importance/triviality):
#    * None

# Programmers' notes: error and trap handling: 
#   * All errors are fatal and exit or finalise() is called.
#   * At any time, a trapped event may transfer control to finalise().

# Programmers' notes: variable names and values
#    * Directory name variables are called *_dir and have values ending in /
#    * File name variables are called *_afn have values beginning with /
#    * Logic flag variables are called *_flag and have values $true or $false
#    * $buf is a localised scratch buffer.
#    * $lf is a line feed.

# Programmers' notes: maximum line length ruler
# -------+---------+---------+---------+---------+---------+---------+---------+
#        10        20        30        40        50        60        70        80

# Programmers' notes: function call tree
#    +
#    |
#    +-- initialise
#    |   |
#    |   +-- ck_email_address
#    |   |
#    |   +-- ck_ip_address
#    |   |
#    |   +-- usage
#    |
#    +-- configure
#    |
#    +-- finalise
#
# Utility functions called from various places:
#     ck_file fct msg

# Function definitions in alphabetical order.  Execution begins after the last function definition.

#--------------------------
# Name: ck_email_address
# Purpose: checks argument is a valid email address
# $1 - value to test
#--------------------------
function ck_email_address {

    fct "${FUNCNAME[ 0 ]}" "started with argument $1"

    if [[ $1 =~ ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$ ]]; then
        fct "${FUNCNAME[ 0 ]}" "returning 0"
        return 0
    else
        fct "${FUNCNAME[ 0 ]}" "returning 1"
        return 1
    fi

}  # end of function ck_email_address

#--------------------------
# Name: ck_ip_address
# Purpose: checks argument is a valid IP address
# $1 - value to test
# Acknowledgments to Mitch Frazier and Linux Journal: http://www.linuxjournal.com/content/validating-ip-address-bash-script
#--------------------------
function ck_ip_address {

    fct "${FUNCNAME[ 0 ]}" "started with argument $1"

    local array oIFS retval

    retval=1

    if [[ $1 =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
        oIFS=$IFS
        IFS='.'
        array=( $1 )
        IFS=$oIFS
        [[ ${array[0]} -le 255 && ${array[1]} -le 255 && ${array[2]} -le 255 && ${array[3]} -le 255 ]]
        retval=$?
    fi

    fct "${FUNCNAME[ 0 ]}" "returning $retval"
    return $retval

}  # end of function ck_ip_address

#--------------------------
# Name: fct
# Purpose: function call trace (for debugging)
# $1 - name of calling function 
# $2 - message.  If it starts with "started" or "returning" then the output is prettily indented
#--------------------------
function fct {

    if [[ ! $debugging_flag ]]; then
        return 0
    fi

    fct_ident="${fct_indent:=}"

    case $2 in
        'started'* )
            fct_indent="$fct_indent  "
            msg 'I' "DEBUG: $fct_indent$1: $2"
            ;;
        'returning'* )
            msg 'I' "DEBUG: $fct_indent$1: $2"
            fct_indent="${fct_indent#  }"
            ;;
        * )
            msg 'I' "DEBUG: $fct_indent$1: $2"
    esac

}  # end of function fct

#--------------------------
# Name: finalise
# Purpose: cleans up and gets out of here
#--------------------------
function finalise {
    fct "${FUNCNAME[ 0 ]}" 'started'

    local buf msg msgs my_retval retval

    # Set return value
    # ~~~~~~~~~~~~~~~~
    # Choose the highest and give message if finalising on a trapped signal
    my_retval="${prgnam_retval:-0}" 
    if [[ $1 -gt $my_retval ]]; then
        my_retval=$1
    fi
    case $my_retval in 
        129 | 130 | 131 | 143 )
            case $my_retval in
                129 )
                    buf='SIGHUP'
                    ;;
                130 )
                    buf='SIGINT'
                    ;;
                131 )
                    buf='SIGQUIT'
                    ;;
                143 )
                    buf='SIGTERM'
                    ;;
            esac
            msg 'I' "finalising on $buf"
            ;;
    esac

    # Final log messages
    # ~~~~~~~~~~~~~~~~~~
    finalising_flag=$true    # Used to avoid infinite recursion
    msgs=
    if [[ $global_warning_flag ]]; then
        msgs="$msgs${lf}There were WARNINGs"
        if [[ $my_retval -eq 0 ]]; then
            my_retval=1
        fi
    fi
    if [[ "$msgs" != '' ]]; then
        msgs="${msgs#$lf}"        # strip leading linefeed
        msg 'E' "$msgs"
    fi
    msg 'I' "Exiting with return value $my_retval"

    # Exit
    # ~~~~
    fct "${FUNCNAME[ 0 ]}" 'exiting'
    exit $my_retval

}  # end of function finalise

#--------------------------
# Name: initialise
# Purpose: sets up environment and parses command line
#--------------------------
function initialise {

    local alias args array i_opt_flag emsg r_opt_flag username

    # Configure shell environment
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    export PATH=/usr/sbin:/sbin:/usr/bin:/bin
    IFS=$' \n\t'
    set -o nounset
    umask 0022
    unalias -a
    
    # Configure traps
    # ~~~~~~~~~~~~~~~
    # Set up essentials for finalise() and what it may call before setting traps 
    # because finalise() may be called at any time after then
    false=
    true=true

    debugging_flag=$false
    finalising_flag=$false
    global_warning_flag=$false
    prgnam=${0##*/}            # program name w/o path
    trap 'finalise 129' 'HUP'
    trap 'finalise 130' 'INT'
    trap 'finalise 131' 'QUIT'
    trap 'finalise 143' 'TERM'

    # Utility variables
    # ~~~~~~~~~~~~~~~~~
    lf=$'\n'                            # ASCII linefeed, a.k.a newline
    prg_ver='0.0'

    # Parse command line
    # ~~~~~~~~~~~~~~~~~~
    aliases=
    args="${@:-}"
    emsg=''
    i_opt_flag=$false
    my_ips=
    pf_fqdn=
    r_opt_flag=$false
    unactioned_aliases=
    while getopts a:dhi:p:r:V opt 2>/dev/null
    do
        case $opt in
            a )
                array=( $OPTARG )
                for (( i=0; i<${#array[*]}; i++ ))
                do
                    username=${array[i]%:*}
                    alias=${array[i]#*:}
                    ck_email_address "$alias" || emsg="$emsg${lf}Option -a: invalid email address: $alias" 
                    grep -q "$username:$alias" /etc/aliases \
                        && unactioned_aliases="$unactioned_aliases${lf}$username: $alias" \
                        || aliases="$aliases${lf}$username: $alias"
                done
                aliases=${aliases#$lf}
                ;;
            d )
                debugging_flag=$true
                ;;
            h )
                usage verbose
                exit 0
                ;;
            i )
                i_opt_flag=$true
                array=( $OPTARG )
                for (( i=0; i<${#array[*]}; i++ ))
                do
                    ck_ip_address ${array[i]} || emsg="$emsg${lf}Option -i: invalid IP address: ${array[i]}" 
                    my_ips="$my_ips ${array[i]}"
                done
                my_ips=${my_ips# }
                ;;
            p )
                pf_fqdn=$OPTARG
                [[ $pf_fqdn =~ ^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,12}$ ]] \
                    || emsg="$emsg${lf}Option -p: invalid domain name: $pf_fqdn"
                ;;
            r )
                r_opt_flag=$true
                IFS=':'
                array=( $OPTARG )
                IFS=
                if [[ ${#array[*]} -ne 4 ]]; then
                    emsg="$emsg${lf}Option -r: incorrect number of relaying SMTP server info components: $OPTARG" 
                else
                    relay_fqdn=${array[0]}
                    [[ $relay_fqdn =~ ^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$ ]] \
                        || emsg="$emsg${lf}Option -r: invalid domain name: $relay_fqdn"
                    relay_port=${array[1]}
                    [[ $relay_port =~ ^[0-9]+$ ]] || emsg="$emsg${lf}Option -r: relaying SMTP port not numeric: $relay_port"
                    relay_username=${array[2]}
                    relay_password=${array[3]}
                fi
                ;;
            V )
                echo "$prgnam version $prg_ver"
                exit 0
                ;;
            * )
                emsg="$emsg${lf}Invalid option '$opt'"
        esac
    done

    # Test for mandatory options not set
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    [[ $i_opt_flag = $false || $my_ips = '' ]] && emsg="$emsg${lf}Mandatory option -i not given or empty option argument"
    [[ $pf_fqdn = '' ]] && emsg="$emsg${lf}Mandatory option -p not given or empty option argument"
    if [[ $r_opt_flag = $false ]]; then
        emsg="$emsg${lf}Mandatory option -r not given"
    elif [[ ${#array[*]} -eq 4 ]]; then
        [[ $relay_fqdn = '' ]] && emsg="$emsg${lf}Option -r: server_FQDN empty"
        [[ $relay_port = '' ]] && emsg="$emsg${lf}Option -r: port empty"
        [[ $relay_username = '' ]] && emsg="$emsg${lf}Option -r: username empty"
        [[ $relay_password = '' ]] && emsg="$emsg${lf}Option -r: password empty"
    fi

    # Test for extra arguments
    # ~~~~~~~~~~~~~~~~~~~~~~~~
    shift $(( $OPTIND-1 ))
    if [[ $* != '' ]]; then
        emsg="$emsg${lf}Invalid extra argument(s) '$*'"
    fi

    # Report any errors
    # ~~~~~~~~~~~~~~~~~
    if [[ $emsg != '' ]]; then
        echo "${emsg#$lf}" >&2
        usage
        exit 1
    fi
    
    # Note whether being run from a terminal
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # The "standard" test is to check $PS1 but this test is more reliable
    buf="$( ps -p $$ -o tty 2>&1 )"
    case $buf in
        *TT*-* )
            interactive_flag=$false
            ;;
        *TT* )
            interactive_flag=$true
            ;;
        * )
            echo "$prgnam: Unable to determine if being run interactively.  ps output was: $buf" >&2
            exit 1
    esac

    # Up to this point any messages have been given using echo followed by exit 1.  Now 
    # the essentials for _msg() and finalise() have been established, all future messages 
    # will be sent using _msg() and error mesages will then call finalise().

    fct "${FUNCNAME[ 0 ]}" 'started (this message delayed until messaging initialised)'

    msg 'I' "$prgnam version $prg_ver started with command line '$args'"
    [[ $unactioned_aliases != '' ]] \
       && msg W "Reqested aliases already in /etc/aliases. Ignored:$unactioned_aliases"

    # Exit if not running interactively
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    if [[ ! $interactive_flag ]]; then
        msg 'E' 'Not running interactively'
    fi

    fct "${FUNCNAME[ 0 ]}" "returning. 
  aliases: $aliases
  my_ips: $my_ips
  pf_fqdn: $pf_fqdn
  relay_fqdn: $relay_fqdn
  relay_port: $relay_port
  relay_username: $relay_username
  relay_password: $relay_password"

}  # end of function initialise

#--------------------------
# Name: configure
# Purpose: configures the postfix server
#--------------------------
function configure {

    fct "${FUNCNAME[ 0 ]}" 'started'

    # Sanity checks
    # ~~~~~~~~~~~~~
    type postfix >/dev/null 2>&1 || msg 'E' "postfix command not found.  Is postfix installed?"
    msg 'I' "$prgnam: checking existing postfix installation ..."
    postfix check && echo 'OK' || while true
    do
        read -p 'Continue?  Y to continue, Q to quit > '
        case $REPLY in
        y|Y ) break ;;
                q|Q ) finalise 0 ;;
                * ) echo "Invalid response '$REPLY'"
        esac
    done

    # Derive variables
    # ~~~~~~~~~~~~~~~~
    pf_uq_hostname=${pf_fqdn%%.*}  # uq = unqualified
    pf_domain_name=${pf_fqdn#*.}
    relay_uq_hostname=${relay_fqdn%%.*}
    relay_domain_name=${relay_fqdn#*.}
    
    # Configure postfix
    # ~~~~~~~~~~~~~~~~~
    msg 'I' "$prgnam: configuring postfix ..."
    set -e    # Let command errors terminate script
    echo $pf_uq_hostname > /etc/mailname
    cd /etc/postfix
    postconf -e smtpd_tls_CAfile=/etc/postfix/cacert.pem
    postconf -e smtpd_tls_cert_file=/etc/postfix/${pf_uq_hostname}-cert.pem
    postconf -e smtpd_tls_key_file=/etc/postfix/${pf_uq_hostname}-key.pem
    postconf -e smtp_tls_CAfile=/etc/postfix/cacert.pem
    postconf -e smtp_use_tls=yes
    postconf -e smtpd_use_tls=yes
    postconf -e myhostname=$pf_fqdn
    postconf -e myorigin=/etc/mailname
    postconf -e mydestination=$pf_fqdn,localhost.$pf_domain_name,localhost
    postconf -e relayhost=[$relay_fqdn]:$relay_port
    postconf -e mynetworks="127.0.0.0/8 $my_ips"
    postconf -e inet_interfaces=all
    postconf -e default_transport=smtp
    postconf -e relay_transport=smtp
    postconf -e smtp_sasl_auth_enable=yes
    postconf -e smtp_sasl_security_options=noanonymous
    postconf -e smtp_sasl_tls_security_options=noanonymous
    postconf -e smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd
    postconf -e smtp_generic_maps=hash:/etc/postfix/generic
    postconf -e transport_maps=hash:/etc/postfix/transport
    postconf -e virtual_alias_maps=hash:/etc/postfix/virtual
    echo "# this is for the sasl_passwd${lf}[$relay_fqdn]:$relay_port $relay_username:$relay_password" > /etc/postfix/sasl_passwd
    echo "# this is for the transport${lf}$relay_domain_name smtp:[$relay_fqdn]:$relay_port" > /etc/postfix/transport
    echo "# this is for the generic${lf}bli@$relay_fqdn $relay_username" > /etc/postfix/generic
    echo "# this is for the virtual${lf}root root@localhost" > /etc/postfix/virtual
    postmap virtual generic sasl_passwd transport
    chmod 400 /etc/postfix/sasl_passwd
    cat /usr/lib/ssl/certs/Equifax_Secure_CA.pem >> /etc/postfix/cacert.pem
    if [[ $aliases != '' ]]; then
        msg 'I' "$prgnam: setting up aliases ..."
    echo "$aliases" >> /etc/aliases
        newaliases
    fi
    set +e

    msg 'I' "$prgnam: restarting postfix ..."
    /etc/init.d/postfix restart

    fct "${FUNCNAME[ 0 ]}" 'returning'
    return 0

}  # end of function configure

#--------------------------
# Name: msg
# Purpose: generalised messaging interface
# Usage: msg class msg_text
#    class must be one of I, W or E indicating Information, Warning or Error
#    msg_text is the text of the message
# Return code:  always zero (exits on error)
#--------------------------
function msg {

    local buf indent line message_text preamble

    class="${1:-}"
    case "$class" in 
        I | 'E' ) 
            ;;
        'W' ) 
            global_warning_flag=$true
            ;;
        * )
            echo "$prgnam: msg: invalid arguments: '$args'" >&2
            exit 1
    esac
    message_text="$2"

    case "$class" in 
        I ) 
            echo "$message_text" >&1
            ;;
        W ) 
            echo "WARNING: $message_text" >&1
            ;;
        E )
            echo "ERROR: $message_text" >&2
            [[ ! $finalising_flag ]] && finalise 1
            ;;
    esac

    return 0

}  #  end of function msg

#--------------------------
# Name: usage
# Purpose: prints usage message
#--------------------------
function usage {
    fct "${FUNCNAME[ 0 ]}" 'started'
    echo "usage: $prgnam [-a alias_list] [-d] [-h] -i ip_address_list -p postfix_server_FQDN -r relay_info_list [-V]" >&2    
    if [[ ${1:-} != 'verbose' ]]
    then
        echo "(use -h for help)" >&2
    else
        echo "  where:
    -a A space separated list of local_user:alias items to be used as aliases.
       Required by most relay servers when the local postfix server FQDN is
       not publicly DNS resolvable.
    -d turns debugging trace on.
    -h prints this help and exits.
    -i local IP address.  If more than one, a space-separated list of local IP addresses.
    -p local postfix server fully qualified domain name (FQDN).
    -r relaying SMTP server information as:
         server_FQDN:port:username:password
       The components must not include a : character
    -V prints the program version and exits.
" >&2
    fi

    fct "${FUNCNAME[ 0 ]}" 'returning'

}  # end of function usage

#--------------------------
# Name: main
# Purpose: where it all happens
#--------------------------
initialise "${@:-}"
configure
finalise 0
Quote:
Originally Posted by cola View Post
What is LSI ?
LS1 is the name of the server postfix is running on; it's nothing special; you best replace it with your own.
Quote:
Originally Posted by cola View Post
I don't have those .db files in /etc/postfix
Which could be part of why it is not working!
Quote:
Originally Posted by cola View Post
Probably your settings is to send email from a gmail account.
Is it possible to send email from local pc address like , useraccount@localhost.localdomain ?
No, the settings are to send mail from a server (error reports etc.) to a sysadmin/personal mail address via Gmail's SMTP server (smart host in postfix terminology). Most (all?) mail service providers will reject mail from domains that are not DNS resolvable. useraccount is OK but localhost.localdomain is not -- for the very good reasons that a) it could be used for spam and b) any reply could not be delivered.
 
Old 11-05-2011, 06:53 AM   #10
cola
Senior Member
 
Registered: Sep 2007
Distribution: Debian
Posts: 1,032

Original Poster
Rep: Reputation: 64
@catkin,

How can i know the server prefix ?
How can i replace the localhost.localdomain with something else that would work ? (useraccount@localhost.localdomain)

And how do you send email with mail command from terminal ? Can you post that command ?

Have you sent email using that main.cf(you posted before) from your local pc with this account 'useraccount@localhost.localdomain' ?

What is the 'from' address you used to send email ? Is this your assigned/specific/fixed 'catkin@gmail.com' every time you send email ?

What's the 'to' address ? Are you able to send email to any email account such as abc@gmail.com or abc@yahoo.com ?

Last edited by cola; 11-05-2011 at 06:58 AM.
 
Old 11-05-2011, 07:23 AM   #11
cola
Senior Member
 
Registered: Sep 2007
Distribution: Debian
Posts: 1,032

Original Poster
Rep: Reputation: 64
I changed the /etc/mailname to 'myhost.site1.example.com' , this is the main.cf
Code:
# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_auth_only = no
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = site1.example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = myhost.localhost.localdomain, site1.example.com, localhost.example.com, localhost
relayhost = [smtp.googlemail.com]:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
From terminal
Code:
echo "Hello world" | mail -s 'subject' abc@yahoo.com
cat /var/log/mail.log
Code:
Nov  4 19:19:28 site1 postfix/smtp[6160]: 20B548AA99: to=<user1@myhost.site1.example.com>, relay=smtp.googlemail.com[74.125.127.16]:587, delay=5, delays=0.1/0/3.9/1, dsn=5.7.0, status=bounced (host smtp.googlemail.com[74.125.127.16] said: 530 5.7.0 Must issue a STARTTLS command first. lt8sm17902795pbb.0 (in reply to MAIL FROM command))
Nov  4 19:19:29 site1 postfix/qmgr[6153]: 20B548AA99: removed
 
Old 11-05-2011, 07:45 AM   #12
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
Quote:
Originally Posted by cola View Post
How can i know the server prefix ?
It probably doesn't matter what you use; try localhost.
Quote:
Originally Posted by cola View Post
How can i replace the localhost.localdomain with something else that would work ? (useraccount@localhost.localdomain)
As I already wrote, @localhost.localdomain will not work. The /etc/aliases file is used to change something like useraccount@localhost.localdomain to something that can work.
Quote:
Originally Posted by cola View Post
And how do you send email with mail command from terminal ? Can you post that command ?
It does not matter. The mail log line in your next post shows you are creating a mail locally and it is being picked up for delivery by postfix.
Quote:
Originally Posted by cola View Post
Have you sent email using that main.cf(you posted before) from your local pc with this account 'useraccount@localhost.localdomain' ?
No. Mostly the mail is generated by root which is aliased to root.<server name>@<valid public email domain name>. You could use something like cola@gmail.com.
Quote:
Originally Posted by cola View Post
What is the 'from' address you used to send email ? Is this your assigned/specific/fixed 'catkin@gmail.com' every time you send email ?
As the last answer.
Quote:
Originally Posted by cola View Post
What's the 'to' address ? Are you able to send email to any email account such as abc@gmail.com or abc@yahoo.com ?
Yes.

Last edited by catkin; 11-05-2011 at 07:57 AM. Reason: disabled "Automatically parse links in text"
 
Old 11-05-2011, 07:55 AM   #13
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
Quote:
Originally Posted by cola View Post
cat /var/log/mail.log
Code:
Nov  4 19:19:28 site1 postfix/smtp[6160]: 20B548AA99: to=<user1@myhost.site1.example.com>, relay=smtp.googlemail.com[74.125.127.16]:587, delay=5, delays=0.1/0/3.9/1, dsn=5.7.0, status=bounced (host smtp.googlemail.com[74.125.127.16] said: 530 5.7.0 Must issue a STARTTLS command first. lt8sm17902795pbb.0 (in reply to MAIL FROM command))
Nov  4 19:19:29 site1 postfix/qmgr[6153]: 20B548AA99: removed
The problem is indicated by "Must issue a STARTTLS command first". There's something wrong with your postfix TLS configuration. You haven't mentioned the files I marked in green above. AFAIK they are necessary to do what you want to do.

I am no postfix expert so cannot examine main.cf and see problems. I cribbed how to configure postfix to do what I (and you) want to do so encapsulated it in the script for convenience.

If you backed up the /etc/postfix directory and the /etc/aliases and /etc/mailname files you could safely run my script. It has to be run as root so caution is prudent and it is a long script so difficult to examine. All the action happens in function configure (search for "function configure"). The script has been successfully used on two servers.
 
Old 11-06-2011, 04:52 AM   #14
cola
Senior Member
 
Registered: Sep 2007
Distribution: Debian
Posts: 1,032

Original Poster
Rep: Reputation: 64
Question

Quote:
Originally Posted by catkin View Post
No. Mostly the mail is generated by root which is aliased to root.<server name>@<valid public email domain name>. You could use something like cola@gmail.com.
What is the 'from' address in your case ? Did/do you use catkin@gmail.com or something like that in /etc/postfix/sasl_passwd ?
 
Old 11-06-2011, 06:37 AM   #15
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
Quote:
Originally Posted by cola View Post
What is the 'from' address in your case ? Did/do you use catkin@gmail.com or something like that in /etc/postfix/sasl_passwd ?
As above, the from address I have used is root.<server name>@<valid public email domain name>. If you do not have a <valid public email domain name> to use, you could use something like cola@gmail.com and put any user and server name information in the subject.

/etc/postfix/sasl_passwd includes the logon name for the SMTP server logon; for the Gmail SMTP server it would be something like cola@gmail.com
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make postfix send email to another postfix in local network (LAN)? h4k33m Linux - Server 9 06-04-2015 05:33 PM
[SOLVED] send email using postfix Xanios Linux - Newbie 5 07-26-2010 01:55 AM
Postfix: help required to configure postfix to redirect email. Wheddod Linux - Software 3 08-20-2008 08:55 AM
Postfix: cant send email from my Windows pc using my postfix mailserver elvisious Linux - Software 8 08-01-2008 08:01 PM
How do I configure postfix master to forward all email to an email server ? hello321_1999 Linux - Software 1 11-18-2004 05:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration