-
Notifications
You must be signed in to change notification settings - Fork 407
Configuring email
- Set up an SMTP account for Teambox to use; make a note of the user name and password
- Edit the ‘outgoing’ section of your config/teambox.yml as appropriate, using the user name and password you noted above
Note: If your e-mails do not get sent and the log shows messages similar to
Net::SMTPSyntaxError (501 <Teambox <no-reply@yourdomain.com>>: "@" or "." expected after "Teambox")
…try setting ‘safe_from’ to true. - Done!
- Set the ‘daily_task_reminder_email_time’ in your config/teambox.yml to your preferred time
- Set up a job on your server’s scheduler which uses script/runner to execute ‘User.send_daily_task_reminders’ every hour.
For example, a cron job would look like this:
0 * * * * /path/to/teambox/script/rails runner -e production "User.send_daily_task_reminders" >> /path/to/teambox/log/cron.log 2>&1
As a user who has permissions to write to the crontab and from in your Teambox directory, you can set this up automatically by running:
bundle exec whenever -w
Note that this will also set up the scheduled incoming mail check (see below)
There are three approaches to this. The Sendgrid method is the preferred system, because it’s compatible with Heroku and simpler to manage.
- One is to configure Sendgrid to process emails and notify Teambox whenever there’s a new one (immediately).
- Another one is to process e-mails periodically by checking a mailbox (scheduler method).
- You can also pipe incoming e-mail directly to the application for immediate processing (pipe method).
The best way to set up incoming email is with Sendgrid, which pings your application every time there’s new email.
1. First we set up a Sendgrid account.
2. Once we’re logged in, we visit http://sendgrid.com/developer/reply.
3. We will be accepting every address like *@reply.yourapp.com. For this, enter “reply.yourapp.com” in Hostname and “http://yourapp.com/hooks/email” in URL. You can choose any subdomain for emails.
4. Good. Now we need to set up a DNS record that tells users that emails sent to whatever@reply.yourapp.com need to be sent to Sendgrid’s mail server. For this, open your DNS settings and create an MX record for “reply.yourapp.com.” pointing to “mx.sendgrid.net.”.
5. Wait some hours for the DNS to propagate. You can check it with “host reply.yourapp.com”. If it returns “mx.sendgrid.net”, it means you can use it. (It may take up to one day for Gmail and others to accept the changes).
6. Configure config/teambox.yml to send email from reply.yourapp.com.
It’s important to use the same subdomain to send and receive emails, in order for replies to work correctly.
This article explains better how this mechanism works for receiving emails, in case you want to debug it.
- Set up an e-mail account for Teambox to use and make a note of the user name and password. This should be a ‘catch-all’ account which collects all mail directed at your server which isn’t sent to an existing address. This will allow Teambox to accept e-mails to addresses named after your projects without having to configure a new e-mail account each time.
- Edit your config/teambox.yml
- Set ‘allow_incoming_email’ to true
- Fill in the ‘incoming’ section as appropriate, using the user name and password you noted above
- Set up a job on your server’s scheduler which runs either script/inbox or the ‘mail:inbox’ rake task on a regular basis.
For example, a cron job to process e-mails every 10 minutes would look like this:
*/10 * * * * cd /path/to/teambox && RAILS_ENV=production /usr/bin/env bundle exec rake mail:inbox >> /path/to/teambox/log/cron.log 2>&1
As a user who has permissions to write to the crontab and from in your Teambox directory, you can set this up automatically by running:
bundle exec whenever -w
Note that this will also set up the daily task reminder (see above)
- Ensure your $RAILS_ENV is set as desired, otherwise the production environment will be assumed
- Configure your mail server to pipe mail for unknown recipients to script/receive_email
For example, an alias for Postfix or Sendmail would look like this:
*: "|/path/to/teambox/script/receive_email"
- Always check your log files for errors first. These will give you an indication of what went wrong.
- Verify that the e-mail user names and passwords in teambox.yml are correct and that you can send/receive e-mail from the account(s)
- If all else fails, try asking for help in the Teambox Community