squeeze : basic Postfix setting

Hi all,

I followed this tutorial.

http://library.linode.com/email/postfix … -6-squeeze">http://library.linode.com/email/postfix/gateway-debian-6-squeeze

because i dont want email server. I just want that system will be able to send email from my linode machine ( dns are managed by Godady, for mylinode.domain.c0m

And i would like to be able to redirect alls other emails for domains which are managed by linode dns like website1.c0m,website2.c0m,..

contact@mywebsite1.c0m to mywebsite1@gmail.c0m

contact@mywebsite2.c0m to mywebsite2@gmail.c0m

I'm a huge newbie in debian and medium in english so sometime it' rock and roll in my head

So my question is very stupid, may i have to comment this block ?
> $remote_user = "REMOTE-USER";

$remote_host = "REMOTE-HOST";

$remote_port = "25";

$remote_ip = "127.0.0.1";

If not what is the default value for $remote_user and host ? Root and mylinode.domain.c0m ( which is actually my reverse dns in linode interface and domain that i put during the package configuration).

Thank,

Florent

8 Replies

Florent,

Here's a few of my notes on setting up postfix to send and receive e-mails:

apt-get remove –purge exim4

apt-get install postfix

select no configuration during the install

vi /etc/postfix/main.cf

add contents similar to the following and adjust the domains and ip address as required:

            #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_key_file = /etc/pki/tls/private/mail.mydomain.com.key
            smtpd_tls_cert_file = /etc/pki/tls/certs/mail.mydomain.com.cert
            smtpd_use_tls = 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 = vps.domain1.co.uk
            alias_maps = hash:/etc/aliases
            alias_database = hash:/etc/aliases
            myorigin = domain1.co.uk
            mydestination =
            relayhost =
            mynetworks = 127.0.0.0/8, xxx.xx.xx.xxx/32
            mailbox_command = procmail -a "$EXTENSION"
            mailbox_size_limit = 0
            recipient_delimiter =
            inet_interfaces = all
            mydomain = domain1.co.uk
            message_size_limit = 104857603
            local_transport = error:no local mail delivery
            local_recipient_maps =
            virtual_alias_maps = hash:/etc/postfix/virtual
            relay_recipient_maps = hash:/etc/postfix/relay_recipients
            transport_maps = hash:/etc/postfix/transport
            relay_domains = domain1.co.uk, domain2.co.uk, domain3.co.uk, domain4.me.uk, domain4.co.uk, domain5.co.uk
            #
            # Specify your NAT/proxy EXTERNAL address here.
            #proxy_interfaces = 
            #
            smtpd_helo_required = yes
            smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender_access, reject_non_fqdn_sender, reject_unknown_sender_domain
            smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination, reject_unauth_pipelining
            smtpd_data_restrictions = reject_unauth_pipelining

run the newaliases command

newaliases

vi /etc/postfix/virtual

add these e-mail addresses to the end of this file (do not leave any white spaces at the end of the file):

            # top of file of last line of comments
            postmaster postmaster@domain1.co.uk
            abuse abuse@domain1.co.uk
            ~
            ~
            ~

Run the postmap command on this file whenever it is change/modified/adjusted

postmap /etc/postfix/virtual

vi /etc/postfix/relay_recipients

add these e-mail addresses to the end of this file (do not leave any white spaces at the end of the file):

            # top of file of last line of comments
            @domain1.co.uk OK
            @domain2.co.uk OK
            @domain3.co.uk OK
            @domain4.me.uk OK
            @domain5.co.uk OK
            @domain6.co.uk OK
            ~
            ~
            ~

This file should contain a complete list of the full e-mail addresses that this server will accept mail for.

In order to test this set just accepts all the e-mail for each domain.

When testing is complete this file should be updated (to a full list of complete e-mail addresses).

Run the postmap command on this file whenever it is change/modified/adjusted

postmap /etc/postfix/relay_recipients

vi /etc/postfix/transport

add these e-mail addresses to the end of this file (do not leave any white spaces at the end of the file):

            # top of file of last line of comments
            domain1.co.uk relay:[xx.xx.xxx.xx]
            domain2.co.uk relay:[xx.xx.xxx.xx]
            domain3.co.uk relay:[xx.xx.xxx.xx]
            domain4.me.uk relay:[xx.xx.xxx.xx]
            domain15.co.uk relay:[xx.xx.xxx.xx]
            ~
            ~
            ~

replace the xx.xx.xxx.xx ip adresses above with the ip addresses of the location that you want to transport mail to.

Run the postmap command on this file whenever it is change/modified/adjusted

postmap /etc/postfix/transport

vi /etc/postfix/sender_access

Add the following and adjust alter add and uncomment as required:

        #Example sender access map file
        #massivespammer@mlm.net 550 No MLM thanks
        #spamtastic.tld 550 Spam is not accepted here
        #hackerguy.net REJECT
        #comedyspam.com OK

Run the postmap command on this file whenever it is change/modified/adjusted

postmap /etc/postfix/sender_access

apt-get install sysv-rc-conf

sysv-rc-conf

remove exim4 and mfs from booting in any run level

add postfix to boot in levels 2,3,4 and 5

/etc/init.d/postfix start

telnet 127.0.0.1 25

Useful commands:

Watch the log as mail is sent(ctrl c - to exit)

tail -f /var/log/mail.log

sync postfix files file file postfix chroot dir

LINUX2

check config

postfix check

mailq

qshape

qshape deferred

postqueue -f

postsuper -r ALL

Use iptables and secure ssh etc to restrict access to the server

Personally I would set your domain to use Linodes DNS servers as well.

Hope this helps.

jk

@theNADS:

Florent,

Here's a few of my notes on setting up postfix to send and receive e-mails:

apt-get remove –purge exim4

apt-get install postfix

select no configuration during the install

vi /etc/postfix/main.cf

add contents similar to the following and adjust the domains and ip address as required:

            #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_key_file = /etc/pki/tls/private/mail.mydomain.com.key
            smtpd_tls_cert_file = /etc/pki/tls/certs/mail.mydomain.com.cert
            smtpd_use_tls = 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 = vps.domain1.co.uk
            alias_maps = hash:/etc/aliases
            alias_database = hash:/etc/aliases
            myorigin = domain1.co.uk
            mydestination =
            relayhost =
            mynetworks = 127.0.0.0/8, xxx.xx.xx.xxx/32
            mailbox_command = procmail -a "$EXTENSION"
            mailbox_size_limit = 0
            recipient_delimiter =
            inet_interfaces = all
            mydomain = domain1.co.uk
            message_size_limit = 104857603
            local_transport = error:no local mail delivery
            local_recipient_maps =
            virtual_alias_maps = hash:/etc/postfix/virtual
            relay_recipient_maps = hash:/etc/postfix/relay_recipients
            transport_maps = hash:/etc/postfix/transport
            relay_domains = domain1.co.uk, domain2.co.uk, domain3.co.uk, domain4.me.uk, domain4.co.uk, domain5.co.uk
            #
            # Specify your NAT/proxy EXTERNAL address here.
            #proxy_interfaces = 
            #
            smtpd_helo_required = yes
            smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender_access, reject_non_fqdn_sender, reject_unknown_sender_domain
            smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination, reject_unauth_pipelining
            smtpd_data_restrictions = reject_unauth_pipelining

run the newaliases command

newaliases

vi /etc/postfix/virtual

add these e-mail addresses to the end of this file (do not leave any white spaces at the end of the file):

            # top of file of last line of comments
            postmaster postmaster@domain1.co.uk
            abuse abuse@domain1.co.uk
            ~
            ~
            ~

Run the postmap command on this file whenever it is change/modified/adjusted

postmap /etc/postfix/virtual

vi /etc/postfix/relay_recipients

add these e-mail addresses to the end of this file (do not leave any white spaces at the end of the file):

            # top of file of last line of comments
            @domain1.co.uk OK
            @domain2.co.uk OK
            @domain3.co.uk OK
            @domain4.me.uk OK
            @domain5.co.uk OK
            @domain6.co.uk OK
            ~
            ~
            ~

This file should contain a complete list of the full e-mail addresses that this server will accept mail for.

In order to test this set just accepts all the e-mail for each domain.

When testing is complete this file should be updated (to a full list of complete e-mail addresses).

Run the postmap command on this file whenever it is change/modified/adjusted

postmap /etc/postfix/relay_recipients

vi /etc/postfix/transport

add these e-mail addresses to the end of this file (do not leave any white spaces at the end of the file):

            # top of file of last line of comments
            domain1.co.uk relay:[xx.xx.xxx.xx]
            domain2.co.uk relay:[xx.xx.xxx.xx]
            domain3.co.uk relay:[xx.xx.xxx.xx]
            domain4.me.uk relay:[xx.xx.xxx.xx]
            domain15.co.uk relay:[xx.xx.xxx.xx]
            ~
            ~
            ~

replace the xx.xx.xxx.xx ip adresses above with the ip addresses of the location that you want to transport mail to.

Run the postmap command on this file whenever it is change/modified/adjusted

postmap /etc/postfix/transport

vi /etc/postfix/sender_access

Add the following and adjust alter add and uncomment as required:

        #Example sender access map file
        #massivespammer@mlm.net 550 No MLM thanks
        #spamtastic.tld 550 Spam is not accepted here
        #hackerguy.net REJECT
        #comedyspam.com OK

Run the postmap command on this file whenever it is change/modified/adjusted

postmap /etc/postfix/sender_access

Ehrm… Shouldn't /etc/postfix/main.cf and /etc/postfix/virtual be the only files that are needed? I have all the emails that postfix receives forwarded to my regular gmail account using /etc/postfix/virtual, I've never had to use any of the other files. /etc/aliases and the newaliases command should only be needed for routing internal emails (e.g. emails to webmaster should go to this user, emails to postmaster should go to that user). The /etc/postfix/virtual can be used to forward from users to another address, or can be used to forward email address on a domain that postfix listens for to another address. Everything else should still be relevant though.

Thanks for your help ! I appreciate.

So for the moment i removed Postfix to Exim.

In fact after my post, i realized that i made a mistake during the setting of Postfix. I ll try again on a new linode soon as possible when i will have more time.

So my first Lamp is ready to use ! it was a big challenge for me.

Regards,

Florent

If you want postfix on your LAMP server, you should be able to experiment with Postfix on the same server, you just need to make sure not to touch any of your LAMP settings or programs. Using a separate machine to be safe isn't a bad idea if you're afraid you'll touch the wrong file. But if you're careful to only edit your Postfix settings and only restart Postfix, you shouldn't have to worry.

@PIKI

If you want postfix to receive mail for a domain and then redirect it to another end destination server you need /etc/postfix/transport, as far as I understand things.

I made an adjustment to my aliases file on my server and the newaliases stuff was hanging in the breeze in my notes.

Anyway, I just thought I would offer a few pointers to the opening poster.

Out of interest, how does the virtual file work on your setup then?

vi /etc/postfix/virtual

piki@piki.com piki@gmail.com

jk

It may also be worth mentioning that I use postfix as a backup mta in case my ISP connection dies. Postfix receives mail and defers delivery for a few minutes before forwarding the any received e-mails to the server that my primary mx record points towards.

The are many ways to configure postfix, but I use the relay_recipients file together with the transport file to restrict the e-mail addresses that the mail server will accept mail from.

jk

@theNADS:

@PIKI

If you want postfix to receive mail for a domain and then redirect it to another end destination server you need /etc/postfix/transport, as far as I understand things.

I've never used it. It doesn't even exist on my server, yet my forwarding works perfectly. I saw a /etc/postfix/relay_domains on another server I used to manage, but only one user had his own personal email setup there, but he still had his stuff in /etc/postfix/virtual along with everybody else on that server (including myself), and it still worked.

@theNADS:

I made an adjustment to my aliases file on my server and the newaliases stuff was hanging in the breeze in my notes.

Right, not really necessary for this. Still useful to know about for routing emails internally on your server.

@theNADS:

Anyway, I just thought I would offer a few pointers to the opening poster.

Out of interest, how does the virtual file work on your setup then?

vi /etc/postfix/virtual

piki@piki.com piki@gmail.com

First I have a "catch all" for any domain that I don't explicitly define (e.g. if postfix receives for several domains, but I only explicitly define one in virtual):

piki piki@gmail.com
piki@ piki@gmail.com

Then, I explicitly define per domain where I want piki's messages going:

piki@piki.com piki@gmail.com
piki@someoneelse.com piki@yahoo.com

@theNADS:

jk

I like jk's :-)

@Piki:

If you want postfix on your LAMP server, you should be able to experiment with Postfix on the same server, you just need to make sure not to touch any of your LAMP settings or programs. Using a separate machine to be safe isn't a bad idea if you're afraid you'll touch the wrong file. But if you're careful to only edit your Postfix settings and only restart Postfix, you shouldn't have to worry.

I think that i will take a second linode to make others tests and to remake a full install…Thanks again.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct