Skip to content

Instantly share code, notes, and snippets.

@dovy
Forked from danielepolencic/Sendy.md
Last active January 12, 2022 19:50
Show Gist options
  • Save dovy/3a82773ffc73b2c725d7 to your computer and use it in GitHub Desktop.
Save dovy/3a82773ffc73b2c725d7 to your computer and use it in GitHub Desktop.
{
"require": {
"php": ">=5.5.0",
"ext-gettext": "*"
}
}

Sendy

Sendy is a self hosted email newsletter application that lets you send trackable emails via Amazon Simple Email Service (SES).

Heroku

You can deploy Sendy on Heroku using the following instructions (I assume you've already installed the heroku toolbelt).

  1. On Heroku, create a new app.
  2. Clone that app to your desktop git clone git@heroku.com:YOURAPP.git -o heroku
  3. Add the free cleardb addon to your project heroku addons:add cleardb
  4. Add the included composer.json file to the root of your cloned directory.
  5. Customise the includes/config.php and include the following snippet to use the ClearDB addon previously selected on Heroku:
   <?php
   define('APP_PATH', 'http://yourdomain.com');

   $url_cleardb = parse_url(getenv("CLEARDB_DATABASE_URL"));

   /*  MySQL database connection credentials  */
   $dbHost = $url_cleardb['host']; //MySQL Hostname
   $dbUser = $url_cleardb['user']; //MySQL Username
   $dbPass = $url_cleardb['pass']; //MySQL Password
   $dbName = substr($url_cleardb["path"],1); //MySQL Database Name

All these settings are necessary to Heroku to automatically hook up the ClearDB add-on. More on the settings here.

  1. Commit all the changes and push to Heroku:
   git add -A .
   git commit -am "Sendy customised for heroku deployment"
   git push heroku master
  1. Follow the remaining Sendy setup steps (http://sendy.co/get-started) starting with Step 5.

Seting up Cron

Cron will make your experience much nicer, and not lock up your site.

  1. Add the heroku scheduler: heroku addons:add scheduler:standard
  2. Open the scheduler: heroku addons:open scheduler
  3. Create two jobs, each with a frequency of 10 mins, and 1x dyno
  • Task 1: php autoresponders.php > /dev/null 2>&1
  • Task 2: php scheduled.php > /dev/null 2>&1

FAQs

You can add your own domain/subdomain easily: heroku domains:add YOUR.DOMAIN.COM Then go to your Domain Registrant and add a CNAME with the value of your app:

Record Name Target
CNAME YOUR YOUR-APP.herokuapp.com.

Replacing of course the name to match the subdomain of your choosing, and appending to your domain record.

@punkhop
Copy link

punkhop commented Sep 8, 2014

+1
So cool that you did this!
I'm having problems uploading CSVs and images to my Sendy server on Heroku - whenever I try, I get this error:
"mkdir(): No such file or directory in /app/includes/subscribers/import-update.php on line 55"

Sendy guy told me to CHMOD the uploads folder, but the Heroku Cedar stack is ephemeral. How do you handle file uploads like csv and jpgs?

Thanks again for these instructions.

@dovy
Copy link
Author

dovy commented Dec 5, 2014

Wow, sorry. Didn't see your comment, why am I not subscribed. Hah. I would just manually push CSV's via git then you avoid that. The issue is because Heroku doesn't let you modify the filesystem. I'm sure there's a way around it. Not sure of it now.

@ratpik
Copy link

ratpik commented Apr 23, 2015

Thanks for this! While I'm able to get Sendy onto heroku, I am having trouble accessing the urls. Sendy defaults to using /login, but because Heroku doesn't pick up the .htaccess file, the url fails. Appending .php works. The solution mentioned here doesn't adapt to heroku - https://sendy.co/troubleshooting#404-error. How did you fix this issue?

@ratpik
Copy link

ratpik commented Apr 23, 2015

Never mind. My .htaccess hadn't gotten deployed because of the .gitignore. Works great, thanks!

@tamvm
Copy link

tamvm commented May 9, 2015

I did the same like the guide and deploy successfully, but when I install the Sendy app, it's still saying that gettext is not enabled: http://i.imgur.com/9hXDw2N.png

I also got some warning during deployment (git push heroku):

remote:        Warning: This development build of composer is over 30 days old. It is recommended to update it by running "/app/.heroku/php/bin/composer self-update" to get the latest version.
remote:        Loading composer repositories with package information
remote:        Installing dependencies from lock file
remote:        Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.

Seems that I still can't make gettext and mod_rewrite work correctly. Any suggestion?

@ssoulless
Copy link

Hi I could achieve use amazon S3 for the file uploading issue with heroku, here is the link where you will find instructions: https://gist.github.com/Wysie/03934b6a79a715772abd

@owenstrevor
Copy link

Can someone explain how to manually push CSV's via git? ie. what to name the files etc.

@dovy
Copy link
Author

dovy commented Jul 28, 2015

@owenstrevor - I never did that, heh.

@owenstrevor
Copy link

@dovy I'm confused. what's the point of this guide if you can't upload emails on heroku hosted sendy?

@ssoulless
Copy link

Hi, I followed instructions for set up cron jobs in heroku, however my autoresponders nor my scheduled emails are working, I read some forums and it says that cron must ron every minute otherwise it will not work, some of you have autoresponders and cheduled emails working with the instructions above?

@bcassedy
Copy link

Hi, I've followed all the setup instructions here and I'm stuck. I was able to install Sendy successfully, but when I go to http://myapp.com/sendy/login and enter my login info, I get the login page again with an error that reads: "Please fill in both email and password."

Sendy troubleshooting docs indicate that mod_rewrite could be the problem. I've checked the compatibility endpoint and it seems mod_rewrite is not enabled. How can I enable this?

@joshteng
Copy link

joshteng commented Feb 1, 2016

I just successfully installed sendy on heroku! Thx for this!

There was an error after pushing up to heroku with this guide as of 2nd February 2016.

If you see an error like this:

2016-02-01T16:46:57.673046+00:00 app[web.1]: [01-Feb-2016 16:46:57 UTC] PHP Fatal error:  'break' not in the 'loop' or 'switch' context in /app/includes/functions.php(5) : eval()'d code(1) : eval()'d code(1) : eval()'d code(1) : eval()'d code(1) : eval()'d code(1) : eval()'d code(1) : eval()'d code(1) : eval()'d code(1) : eval()'d code(1) : eval()'d code(1) : eval()'d code(1) : eval()'d code(1) : eval()'d code(1) : eval()'d code(1) : eval()'d code on line 3

Tweak composer.json file in this gist should be modified to use PHP 5 instead of any versions of PHP above 5.5 which may end up using PHP 7 on Heroku.

composer.json should be:

{
    "require": {
        "php": "^5.5.0",
        "ext-gettext": "*"
    }
}

I chose to use PHP 5.5. I suppose 5.6 or 5.7 should work as well. Should probably use the latest to avoid security vulnerabilities.

@tam-vo
For guys getting this error:

remote:        Warning: This development build of composer is over 30 days old. It is recommended to update it by running "/app/.heroku/php/bin/composer self-update" to get the latest version.
remote:        Loading composer repositories with package information
remote:        Installing dependencies from lock file
remote:        Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.

Make sure to run composer update!

For those not familiar with composer, you need to first install it. https://getcomposer.org/download/

I don't code in PHP so I had to install PHP on my mac with brew install php56 https://github.com/Homebrew/homebrew-php

@OElesin
Copy link

OElesin commented Mar 24, 2017

Need help with my deployment. Works fine on Heroku. However, when I schedule a campaign, the scheduler runs and sends to zero recipients. What could be the problem?

@arukanoido
Copy link

arukanoido commented Dec 7, 2017

Installs ok, but there can be some unforseen issues.

  • Importing email list by CSV doesn't work until you add this to composer.json
    "scripts": {
        "compile": [
          "mkdir -p -m 777 uploads/csvs/"
        ]
    }
  • ClearDB is limited to a maximum of 3600 queries per hour. If you go over this limit, for example by importing a long email list, the database will stop responding for an hour, giving the site the appearance of being broken.
  • Cron jobs run every 10 minutes don't work, so that breaks a lot of functionality.

@lexjacobs
Copy link

Thanks a lot for this. I got an initial install on Heroku with this guide. But it turns out that Heroku has problems with regard to the ephemeral filesystem and permissions for the /uploads folder. Reading more posts from the Sendy community, I finally went with DigitalOcean as the host.

I fully documented my install process here: https://medium.com/@alexjacobs/installing-sendy-as-a-replacement-for-mailchimp-2019-update-the-complete-guide-with-automated-5a59c4bd7249

It includes enabling https / making daily mysql backups / archiving the mysql backups in an AWS S3 bucket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment