25 Sep 2014, 7:10pm
linux:

leave a comment




  • Anzeige
  • Setting up a linux server to forward all incoming mails

    Typ­i­cal thing when hav­ing a new site up: you want to get whatever@yourdomain.com to end up in you nor­mal inbox, say Gmail.

    Here are the steps!
    Note: If you are logged in as root, you do not need to use “sudo” in front of each command.

    Prepa­ra­tions

    It’s rec­om­mended to have a user account to receive the mail other than root.
    So either choose a user you have cre­ated already or cre­ate a new one:

    sudo adduser [username]

    Does your provider require you to use an SMTP relay? (check the doc­u­men­ta­tion, or ask). You need to know this to continue.

    Install post­fix

    Post­fix is a soft­ware pack­age, a MTA, it han­dles incom­ing mail and forwarding.

    sudo apt-get install postfix

    And answer all con­fig­u­ra­tion ques­tions as below:
    Server con­fig­u­ra­tion type: If you use an SMTP relay, choose “Inter­net with smarthost”, oth­er­wise “Inter­net“
    Sys­tem mail name: [yourdomain.com] (no sub­do­main)
    SMTP relay host: [smtp.yourprivider.com] (only show­ing if you chose “Inter­net with smarthost”)
    Root and post­mas­ter mail recip­i­ent: The created/chosen before (not root)
    Other des­ti­na­tions to accept mail for: keep the sug­gested defaults and add in front [yourdomain.com] and a space
    Force syn­chro­nous updates on mail queue: no
    Local net­works: keep sug­gested
    Use proc­mail for local deliv­ery?: yes
    Mail­box size limit: 0
    Local address exten­sion char­ac­ter: +
    Inter­net pro­to­cols to use: all

    Man­ual configuration

    All edits with sudo if you not logged in as root.
    Edit /etc/postfix/main.cf add fol­low­ing two lines to the end

    virtual_alias_domains = [yourdomain.com]
    virtual_alias_maps = hash:/etc/postfix/virtual

    Create/edit /etc/postfix/virtual and add

    @[yourdomain.com]    [your.email.address@somewhere.com]

    Finally, after edit­ing this file call

    sudo postmap /etc/postfix/virtual

    so that postmap actu­ally applies your changes.

    Notes

    If you for­ward to Gmail, do not use the same address to send test mails that the mails will be for­warded to — Gmail will silently ignore/delete mail where the sender and recip­i­ent are the same and you will think the for­ward­ing does not work.

    *name

    *e-mail

    web site

    leave a comment