You'll notice a number of fields that need to be populated (e.g. App Name and the Config Variables). Choose an App name, and populate the API credentials fields with your production API credentials from Phaxio.
Skip to section 2 below.
- Install and configure the Heroku CLI. Create an account if you do not already have one.
- Clone this repository:
git clone https://github.com/phaxio/phax_machine.git && cd phax_machine
- Create the app on Heroku:
heroku create
- Set the required environment variables:
heroku config:set PHAXIO_API_KEY=your_api_key
heroku config:set PHAXIO_API_SECRET=your_api_secret
- Deploy:
git push heroku master
- Sign up for a Mailgun account.
- In the Mailgun console, choose the "Domains" tab, then click the "Add New Domain" button, and enter the subdomain where you want to receive fax emails. In these examples, I'm using
phaxmail.myapp.com
. If you don't want to configure your own domain, you can use the sandbox domain already in your Mailgun account, but you'll have to manually add permitted user emails for the domain on Mailgun. If you're using the sandbox domain, you can skip to step 4 below. - Verify your domain. Mailgun will provide you with straight-forward guides on how to do this with most common providers. This step may take some time.
- On the domains page, select the domain that you'll be using. (This can be the sandbox domain in your account which ends mailgun.org.)
- In the Domain Information section, copy and paste the SMTP Hostname into the SMTP_HOST field on Heroku.
- Next copy and past the Default SMTP Login from Mailgun into the SMTP_USER field on Heroku.
- Copy and paste the Default Password from Mailgun into the SMTP_PASSWORD field on Heroku.
- Use port 587 as the SMTP port, mark SMTP_TLS as true, and enter the email address you'd like the emails to come from in the SMTP_FROM field.
- Click Deploy!
- Once your domain at Mailgun has been verified, choose the "Routes" tab, then click the "Create a Route" button
- On the "Create New Route" page, choose "Match Recipient" for the Expression Type, and in the Recepient field enter the following pattern (substituting the domain you previously configured):
[0-9][email protected]
. Then, under "Actions", tick the "Forward" box and enter the URL for your instance of PhaxMachine, followed by/mailgun
(e.g. If you're using a quick and dirty Heroku installation, this url might look something like https://WHATYOUNAMEDYOURAPP.herokuapp.com/mailgun.) The other fields should be left alone, and once you're finished click the "Create Route" button. - (Optional, only needed if you want to test that fax-to-email and email-to-fax are working) Open your instance of PhaxMachine, click on the "Manage Users" link at the top, and add create a user with your email and phaxio fax number.
- (Optional) Test that everything is working correctly by sending an email with an attachment in the following format:
[email protected]
(substituting the phone number and domain). Phone Numbers should not contain any special characters. If everything is set up correctly, you should have just sent a fax.
-
Head to the Callback URL's page in Phaxio.
-
In the second field which says "POST (or send email) to the above URL when a fax has been received," enter your application url followed by '/fax_received' (e.g. If you're using a quick and dirty Heroku installation, this url might look something like https://WHATYOUNAMEDYOURAPP.herokuapp.com/fax_received. Note: if you're using the quick and dirty setup, your faxing emails might be in your spam folder! )
-
(Optional) Test the everything is working correctly by sending a fax to your Phaxio number and and seeing if it shows up in your email inbox! Note: make sure to check your spam folder!
If you want to merge the latest code from this repository into a PhaxMachine instance deployed with the button above, you'll need to follow these instructions:
- Clone this repository:
git clone https://github.com/phaxio/phax_machine.git
- Add the heroku repository as well:
git remote add heroku https://git.heroku.com/HEROKU-APP-NAME.git
(SubstitutingHEROKU-APP-NAME
with the name of your Heroku app) - Push the latest changes to Heroku:
git push heroku master