2 title = "Email & Webhooks"
5 slug = "email-webhooks"
6 aliases = ["email-config"]
9 Within BookStack email is used in various ways relating to user management & authentication.
10 Outgoing webhooks are available as a mechanism to extend BookStack or notify in an event-driven manner.
16 ### Email Configuration
18 BookStack sends out emails for a range of purposes such as email-address confirmation & "forgot password" flows.
19 Both SMTP and Sendmail (Linux Sendmail) are supported email mechanisms.
23 To get up and running with SMTP you will need to add, or set, the following variables in your `.env` file:
28 # SMTP server host address
29 MAIL_HOST=smtp.provider.tld
32 # Using port 465 will force connections to be via TLS
35 # Connection encryption to use
36 # Valid values are: tls, null
37 # Using 'tls' will require either TLS or STARTTLS to be used.
38 # When using 'null' STARTTLS will still be attempted if announced
39 # as supported by your SMTP server.
40 # Using port 465 above will force connections to be via TLS.
43 # Authentication details for your SMTP service
45 MAIL_PASSWORD=onlyifneeded
47 # The "from" email address for outgoing email
50 # The "from" name used for outgoing email
51 MAIL_FROM_NAME=BookStack
54 ##### Connection TLS/SSL Certificate Verification
56 In some cases your SMTP server may be using a private/self-signed TLS/SSL certificate that would usually fail certificate verification.
57 In these cases its common for that certificate (Or its CA) to be added to the BookStack's host trusted certificate database.
58 If that's not possible, you can alternatively disable SSL/TLS certificate verification for mail sending
59 by adding this setting to your `.env` file:
62 # Verify SSL/TLS certificates during SMTP sending
63 # WARNING: Disabling verification using a 'false' value
64 # can make you vulnerable to MITM attacks
70 The `sendmail` drivers uses the sendmail application on the host system. By default it will call `/usr/sbin/sendmail -bs` although this is configurable.
72 To enable this option you can set the following in your `.env` file:
77 # The "from" email address for outgoing email
80 # The "from" name used for outgoing email
81 MAIL_FROM_NAME=BookStack
83 # The command to use for calling sendmail
84 MAIL_SENDMAIL_COMMAND="/usr/sbin/sendmail -bs"
89 Failed email sends are handled differently depending on what triggers them.
90 In some cases, like for user invites, an error will be shown to the user within BookStack since the email
91 is required to perform the intended action.
92 In other cases, like user activity/watch notification emails, failure of email send will not be shown
93 to the BookStack user performing activity, but the error will just be logged to the application error log file.
95 You can follow the instructions provided in the [debugging documentation page](/docs/admin/debugging/)
96 to help gain more details about issues you may come across. Within the "Settings > Maintenance" area of
97 BookStack you can find a "Send a Test Email" action which provides a quick & easy way to send emails
98 after changing your configuration. This action will also attempt to capture any errors thrown and display them.
102 ### Outgoing Webhooks
104 Webhooks can be configured in the "Settings > Webhooks" area of your BookStack instance.
105 An example of the POST data format is shown when creating or editing a webhook.
107 The webhook data is "Slack Compatible" in respect to having a `text` property containing a human-readable description
108 of the event. Services such as [Discord](https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook), [Zulip](https://zulip.com/integrations/doc/slack_incoming) and Teams, upon many others, have options to support this format.
110 A video guide on BookStack webhooks, including usage with Discord and HomeAssistant, [can be found here](https://foss.video/w/xu4T7mafyLqkLU1VTgNaCV).
112 The running of webhooks can slow down a system due to the required additional processing time.
113 See the [async action handling](#async-action-handling) section below to details on running webhooks
114 in a background process to improve performance.
119 ### Async Action Handling
121 Actions like sending email or triggering webhooks are performed synchronously by default which can
122 slow down page loading when those actions are triggered. These actions can instead be processed asynchronously
123 so they're handled in the background to prevent slowing down the request. This requires a config change
124 and a queue worker process to handle these background jobs:
128 Within your `.env` file add or update (if already existing) the following option then save the file.
131 QUEUE_CONNECTION=database
134 #### Queue Worker Process
136 The queue work process can be run via the following command from your BookStack installation directory:
139 php artisan queue:work --sleep=3 --tries=3
142 Ideally this needs to be ran continuously. The method of doing this may depend on your operating system
143 and personal software preferences. On many modern Linux systems systemd is an appropriate method.
144 The below unit file example can be used with systemd to run this process. Note, this is suited to
145 Ubuntu 20.04 setups that have used our installation script. Details may need tweaking for other systems.
149 Description=BookStack Queue Worker
155 ExecStart=/usr/bin/php /var/www/bookstack/artisan queue:work --sleep=3 --tries=1 --max-time=3600
158 WantedBy=multi-user.target
161 To configure systemd (On a Ubuntu 20.04 system) with the above unit you'd typically:
163 - Create a new `/etc/systemd/system/bookstack-queue.service` file containing the above content.
164 - Run `systemctl daemon-reload` to discover the new service.
165 - Run `systemctl enable bookstack-queue.service` to ensure the service starts at (re)boot.
166 - Run `systemctl start bookstack-queue.service` to start the queue service.
168 Note: you may need to run the above commands with `sudo` if not acting as a privileged user.
170 You can then use `systemctl status bookstack-queue.service` to check the status of the queue worker.