Configure Seafile To Send Emails Through Gmail

You need to configure Seafile to be able to send emails in order to have new users sent their password via email, or for the user to recieve password reset notifications. This tutorial will show you how to configure Seafile to use your existing Gmail account in order to send emails. If you are a business with an AWS account, then you may wish to configure Seafile with SES SMTP instead.

Steps

The first thing you need to do is create an app-specific password in your gmail account. That way if your server becomes compromised and a malicious user manages to retrieve your password, you can remove that password from your account and not have to reconfigure the rest of your applications with new a password.

Now edit your settings.py file at /path/to/seafile-server-latest/seahub/seahub/settings.py and find the section below:

...
#################
# Email sending #
#################
...

Add the lines below (if they haven't already been added by you or somebody else) and make sure to change the values of EMAIL_HOST_USER and EMAIL_HOST_PASSWORD.

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'username@gmail.com'
EMAIL_HOST_PASSWORD = 'my-app-specific-password'
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER

Restart Seahub

For the changes to take effect you need to run:

./seahub.sh stop
./seahub.sh start

To test that everything is working, execute a password reset. A pop-up will appear and tell you if it managed to send the email or if your configuration is incorrect.

References

Author

Programster

Stuart is a software developer with a passion for Linux and open source projects.

comments powered by Disqus