How to setup a mail server?

前端 未结 4 1144
攒了一身酷
攒了一身酷 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.

    0 讨论(0)
  • 2021-01-23 07:39

    Install and configure an SMTP server. SMTP servers can usually be configured quite extensively, what to do with mails that should be deliverd locally. One such option would be to deliver the mail locally by invoking a ruby script. Popular SMTP servers are postfix, courier and qmail. The details about how to setup the mail server depends on which one you use.

    0 讨论(0)
  • 2021-01-23 07:42

    An alternative to setting up and configuring a mail server is to use a service such as sendgrid or postmark. You point your DNS mx records at them and they will turn inbound messages into JSON documents and post them to you

    0 讨论(0)
  • 2021-01-23 07:54

    If you've never set up an smtp server, and you're not willing to dig in and learn a lot, you might want to check out some of the services that offer this kind of ability. I have never used any of these, not sure about quality or pricing aspects.

    • cloudmailin
    • mailgun
    • dispatch
    • postmark
    0 讨论(0)
提交回复
热议问题