How to setup a mail server?

前端 未结 4 1148
攒了一身酷
攒了一身酷 2021-01-23 07:12

I want anyone who send a email to test@example.com, and the server could get the mail and so I can use some server side scripting language like Ruby to parser the content of the

4条回答
  •  悲哀的现实
    2021-01-23 07:28

    You can install qmail on your server, and configure it to pipe incoming mail to your domain to the STDIN of your ruby script.

    If you haven't done so already, create an MX record for your domain that points to your mailserver's IP. Then, login to the server as root, then install qmail by following the instructions at http://lifewithqmail.org/lwq.html#installation

    Configure qmail to accept incoming mail for *@yourdomain.tld (catchall), and forward all incoming mail to the script at /home/yourhomedirectory/yourscript.sc:

    add the following line to /var/qmail/control/me:
    hostname.yourdomain.tld
    
    add the following line to /var/qmail/control/defaultdomain: 
    yourdomain.tld
    
    affffd the following line to /var/qmail/control/virtualdomains
    yourdomain.tld:yourusername
    
    add the following line to /var/qmail/control/rcphosts:  
    yourdomain.tld
    
    restart qmail:
    qmailctl stop
    qmailctl stat
    

    Logout of the server, then log back in again as yourusername. Create a file /home/yourusername/.qmail-default, consisting of the following line: | /home/yourhomedirectory/yourscript.sc

    Create /home/yourhomedirectory/yourscript.sc script to process incoming mail. Enable executable permissions on the script for all users: chmod a+x /home/yourhomedirectory/yourscript.sc

    That's all there is to it. Incoming mail to your domain will be piped by qmail to this script's STDIN.

提交回复
热议问题