list

server

This is the main dovel repository, it has the Go code to run dovel SMTP server.

curl -O https://dovel.email/server.tar.gz tar.gz

doc.go

  1. // server is a SMTP server that is simple to setup and use.
  2. //
  3. // The binary is the main server, this server is responsible to receive your
  4. // emails and save them according to your hooks. As well as sending them.
  5. //
  6. // # Setting up your email server
  7. //
  8. // Email works in a complex way, DNS records must match your server's
  9. // configuration. This guide will try to give more detailed information
  10. // in comparison with the website tutorial.
  11. //
  12. // An email server typically listens on ports 25, 2525, 587 or 465 for mail
  13. // exchange. But their use differ:
  14. //
  15. // - 25: is the original SMTP port and first to be official by RFC.
  16. // - 465: is marked as deprecated.
  17. // - 587: is also official by RFC, this port is used for TLS encrypted mail.
  18. //
  19. // The current recomendation is to use port 587. Dovel works with any port,
  20. // and the value must be set in the port field of the config file. To
  21. // configure this server see [Config].
  22. //
  23. // # Server configuration
  24. //
  25. // This section is dedicated to help you correctly run your dover server. The
  26. // configuration is done using a single config file which should be located
  27. // in $XDG_CONFIG_DIR/dovel/config.json which normaly expands to
  28. // ~/.config/dovel/config.json.
  29. // The structure of this config file is [model.Config]. See that doc for more
  30. // details. The following example should be enough to receive emails:
  31. //
  32. // {
  33. // "Port": "2525",
  34. // "Domain": "my.domain",
  35. // "ReadTimeout": 30,
  36. // "WriteTimeout": 30,
  37. // "MaxMessageBytes": 5000000,
  38. // "MaxRecipients": 5,
  39. // "Certificate": "fullchain.pem",
  40. // "PrivateKey": "privkey.pem"
  41. // }
  42. //
  43. // Note that Certificate and PrivateKey are given so that your server can use
  44. // TLS connections, this is desired for enhanced security. In cases where
  45. // proxies are used in front of servers, for doing the TLS handshake, setting
  46. // certificates here is not necessary.
  47. //
  48. // # Receiving emails
  49. //
  50. // To receive email the MX record must be correctly set on your registrar,
  51. // make sure it is pointing to your server where dover is running. Everytime
  52. // dovel receives an email it searches for an executable file in
  53. // $XDG_CONFIG_DIR/dovel/hooks/ named receive-DOMAIN, for the DOMAIN receiving
  54. // the email and executes it passing the email in mbox format as standard
  55. // input. Then it is up to the script to decide what to do. See the scripts
  56. // repo for examples, one simple is given in the next section.
  57. //
  58. // # Hooks
  59. //
  60. // A simple hook is a shell script that simply concatenates the received email
  61. // to a .mbox file, e.g. to receive email for your domain create a file named
  62. // receive-<DOMAIN> in the hooks folder with the following content:
  63. //
  64. // #!/bin/sh
  65. // cat >> ~/mail/dovel.mbox
  66. //
  67. // Be sure to make the file executable. Now whenever an email to the domain
  68. // DOMAIN it will be appended to the ~/mail/dovel.mbox file, which you can
  69. // later open and read.
  70. //
  71. // # Configuring DNS records
  72. //
  73. // To receive emails you need to setup the MX record in your domain registrar,
  74. // sending email is more complicated, some receiving servers only need the SPF
  75. // and PTR records, some also need DKIM and DMARC, adjust according to your
  76. // needs. Configuring DNS records is not the goal of this doc.
  77. //
  78. // # DKIM configuration
  79. //
  80. // DKIM in dovel is handled in a per-user basis only for sending emails,
  81. // for receiving emails it is up to the corresponding hook. This means that
  82. // each user have to setup its DKIM key. Luckily this is simply pointing
  83. // the key path in the [User] struct.
  84. //
  85. // # Sending email
  86. //
  87. // Dovel also sends email, for that it needs a valid VaultFile path on the
  88. // config. That means you need at least one user described on the json file.
  89. // The format of that file is a JSON array of the [model.User] struct. Here's
  90. // one example:
  91. //
  92. // [
  93. // {
  94. // "Name": "user1@my.domain",
  95. // "PrivateKey": "dkim.priv",
  96. // "Password": "1234"
  97. // }
  98. // ]
  99. //
  100. // This means the user1@my.domain is allowed to send emails, also as its DKIM
  101. // key was passed it will be used to sign the email using the DKIM guidelines.
  102. // This is optional.
  103. //
  104. // You can use any email client to communicate with your dovel server. When an
  105. // email comes from the domain configured, Dovel will known you want to send
  106. // the email, and will check if the sending user is valid using the configured
  107. // users, in positive case the email is sent, and the hook named send-<DOMAIN>
  108. // for the domain used is run passing the sent email as input.
  109. // The success of this hook does not impact one the sent email, it is mainly
  110. // used for storing it.
  111. //
  112. // # Debuging your server
  113. //
  114. // Dovel will issue debugging logs for the developer's convenience by setting
  115. // the DEBUG environment variable to any non-empty value at the time the server
  116. // is started, e.g.:
  117. //
  118. // DEBUG=1 ./server
  119. //
  120. package main