New Install on CentOS at Digital Ocean, working great!

Use this forum for questions regarding installation, upgrading and configuration of OpenEMM

Moderator: moderator

jim_frey
Posts: 132
Joined: Wed Nov 29, 2006 11:32 pm
Location: Middle Caicos, Turks and Caicos Islands
Contact:

New Install on CentOS at Digital Ocean, working great!

Post by jim_frey »

I just did a new install of OpenEMM on some cloud space at DigitalOcean.com
It'd be nice if OpenEMM could be one of the one-click applications like these
https://www.digitalocean.com/products/one-click-apps/

Once I got it all set up and configured properly, it was great to be able to take a snapshot of the installation and a minute later have a second installation working that just needed some of the config files altered for the different domain name.

I have everything working, DKIM, SPF, DMARC and all.
A few notes from the install -

*************************************************************************************************************
From section 3.3 of the OpenEMM-2015_InstallAdminGuide_1.3.pdf
I am using the Internal SMTP of OpenEMM which relays to sendmail for the DKIM signing. To disable sendmail in OpenEMM you enter:

Code: Select all

/home/openemm/bin/sendmail-disable.sh
Then create a relay file so OpenEMM relays to sendmail:

Code: Select all

echo "127.0.0.1" > /home/openemm/conf/smart-relay
And I have OpenDKIM installed on sendmail

*************************************************************************************************************
From section 8.5 of the OpenEMM-2015_InstallAdminGuide_1.3.pdf
It was working on their $10 a month hosted plan, but after a while of sending emails it seemed the 1G of memory wasn't enough (Java wants more.) So now I have it at the $20 a month plan with 2G of RAM and so far so good.

*************************************************************************************************************
From section 13.3 of the OpenEMM-2015_InstallAdminGuide_1.3.pdf
I couldn't get 13.3 part A to work, but I think that's because the OpenEMM SMTP is picking up the mail and not sendmail so the /etc/alias file isn't used. I was able to get 13.3 part B to work which is pretty simple. Create the file -

Code: Select all

/home/openemm/conf/bav/bav.conf-local
With the information of the relay address you want to use

Code: Select all

noreply@mydomain.com alias:ext_1@mail.mydomain.com
*************************************************************************************************************
For the unsubscribe embedded link in the email header
change the file
/home/openemm/conf/semu/semu.cfg
To include the proper url of an unsubscribe link which I create at

Code: Select all

uri: http://www.mydomain.com/form.do?agnCI=1&agnFN=remove
That link is created by making a form in OpenEMM which subscribes the email with a status of zero (so it's actually unsubscribing)
The form name is "remove", it has no action, and it looks like this

Code: Select all

<html>
<head>
<title>Remove</title>
</head>
<body>
<p>
<form action="form.do" method="post">

<input type="hidden" name="agnCI" value="1">
<input type="hidden" name="agnFN" value="removedone">

<input type="hidden" value="1" name="agnMAILINGLIST">
<input type="hidden" value="0" name="agnSUBSCRIBE">

<b>Enter your email address to be removed</b><br>
<input type="text" value="$!requestParameters.email" name="EMAIL" size="30"><br>

<input type="submit" value="submit">

</form>
</p>
</body>
</html>
Then there is the form "removedone" that has the action of "Subscribe"
The "removedone" success form just says "You have been removed."
The "removedone" error form just says "You are not on the list."

The action of "Subscribe" looks like this, you will need to adjust this for which list numbers you want to have the email address unsubscribed from

Code: Select all

    ##unsubscribe script for more mailinglists

    ##set Company ID
    #set($company = 1)

    ##Check the availability of the customer
    #if($customerID != 0)
      $BindingEntry.setCustomerID($customerID)

      ##define second mailinglist
      $BindingEntry.setMailinglistID(3)

      #if($BindingEntry.getUserBindingFromDB($company) == true)
         #if($BindingEntry.getUserStatus() == 1)
           $BindingEntry.setUserStatus(3)
           $BindingEntry.setUserRemark("Opt-Out by Script")
           $BindingEntry.updateBindingInDB($company)
           #set($result1="checked out from list B")
         #else
           #set($result1="not active on list B")
         #end
      #else
         #set($result1="without binding to list B")
      #end

      ##define third mailinglist
      $BindingEntry.setMailinglistID(4)

      #if($BindingEntry.getUserBindingFromDB($company) == true)
         #if($BindingEntry.getUserStatus() == 1)
           $BindingEntry.setUserStatus(3)
           $BindingEntry.setUserRemark("Opt-Out by Script")
           $BindingEntry.updateBindingInDB($company)
           #set($result1="checked out from list B")
         #else
           #set($result1="not active on list B")
         #end
      #else
         #set($result1="without binding to list B")
      #end

    #else
      #set($result="not a customer of our mailings")
      #set($result1="not a customer of our mailings")
    #end

    ##necessary for a successful result
    #set($scriptResult="1")
*************************************************************************************************************
Also change some of the email header formats to match your domain
Open the file

Code: Select all

/home/openemm-2015/webapps/openemm/WEB-INF/classes/emm.properties
Change the settings on:

Code: Select all

system.url=http://www.mydomain.com
mailgun.ini.domain=mydomain.com
mailgun.ini.mailer=My Company Name
*************************************************************************************************************

I hope my notes might help someone else too. And who knows, maybe Digital Ocean can have OpenEMM as a one click install someday soon too!
OpenEMM Moderator
jim_frey
Posts: 132
Joined: Wed Nov 29, 2006 11:32 pm
Location: Middle Caicos, Turks and Caicos Islands
Contact:

Re: New Install on CentOS at Digital Ocean, working great!

Post by jim_frey »

It's also a good idea to add in a crontab that deletes the archives of the daily mailings, otherwise they just fill disk space.

Open crontab to edit

Code: Select all

crontab -e
Add in this line

Code: Select all

0 1 * * * rm -rf /home/openemm/var/spool/ARCHIVE/$(date +'\%Y\%m\%d' -d "yesterday")
OpenEMM Moderator
jim_frey
Posts: 132
Joined: Wed Nov 29, 2006 11:32 pm
Location: Middle Caicos, Turks and Caicos Islands
Contact:

Re: New Install on CentOS at Digital Ocean, working great!

Post by jim_frey »

And create a init.d file so you can start and stop openemm by just calling

Code: Select all

service openemm start
service openemm stop
create the file /etc/init.d/openemm (thanks to another forum post for this one)

Code: Select all

#! /bin/sh
#
# chkconfig: 345 80 20
# description: OpenEMM server
# processname: openemm
#
# System startup script for OpenEMM
#
openemmbin=/home/openemm/bin/openemm.sh

case "$1" in
    start)
        echo -n "Starting OpenEMM"
        su - openemm -c "$openemmbin start"
        ;;
    stop)
        su - openemm -c "$openemmbin stop"
        ;;
    *)
        echo "Usage: $0 {start|stop}"
        exit 1
        ;;
esac
OpenEMM Moderator
jim_frey
Posts: 132
Joined: Wed Nov 29, 2006 11:32 pm
Location: Middle Caicos, Turks and Caicos Islands
Contact:

Re: New Install on CentOS at Digital Ocean, working great!

Post by jim_frey »

Here's a quick Perl script to backup email lists and mail them to you. I set this up on a daily crontab, just in case

Code: Select all

#!/usr/bin/env perl

use DBI;
use Data::Dumper;
use MIME::Lite;

my $emailfrom = 'server@email.com';
my $emailto = 'your@email.com';
my $emailsubject = 'Backup of Emails';
my $emailbody = 'Backup';

########################
my $dbh = DBI->connect('DBI:mysql:openemm', 'root', '') or die "Can't connect to database $DBI::errstr\n";
my $sth = $dbh->prepare("select customer_1_tbl.email from customer_1_tbl,customer_1_binding_tbl where customer_1_tbl.customer_id=customer_1_binding_tbl.customer_id and customer_1_binding_tbl.user_status=1 and customer_1_binding_tbl.mailinglist_id=1;" );
my $rv = $sth->execute();
my @emails1;
while(my $row = $sth->fetchrow_array){
        push @emails1, $row;
}
$sth->finish;
my $rc  = $dbh->disconnect;
my $emailfile1;
foreach my $email (@emails1){
        $emailfile1 = $emailfile1.$email."\n";
}
##########################
my $dbh = DBI->connect('DBI:mysql:openemm', 'root', '') or die "Can't connect to database $DBI::errstr\n";
my $sth = $dbh->prepare("select customer_1_tbl.email from customer_1_tbl,customer_1_binding_tbl where customer_1_tbl.customer_id=customer_1_binding_tbl.customer_id and customer_1_binding_tbl.user_status=1 and customer_1_binding_tbl.mailinglist_id=2;" );
my $rv = $sth->execute();
my @emails2;
while(my $row = $sth->fetchrow_array){
        push @emails2, $row;
}
$sth->finish;
my $rc  = $dbh->disconnect;
my $emailfile2;
foreach my $email (@emails2){
        $emailfile2 = $emailfile2.$email."\n";
}
##########################


$msg = MIME::Lite->new(
        From    => $emailfrom,
        To      => $emailto,
        Subject => $emailsubject,
        Type    => 'multipart/mixed'
);
$msg->attach(
        Type     =>'TEXT',
        Data     =>$emailbody
);
$msg->attach(
        Type     => 'test/csv',
        Encoding => 'base64',
        Filename => 'opened.txt',
        Data     => $emailfile1,
        Disposition => 'attachment'
);
$msg->attach(
        Type     => 'test/csv',
        Encoding => 'base64',
        Filename => 'unopened.txt',
        Data     => $emailfile2,
        Disposition => 'attachment'
);
$msg->send();


OpenEMM Moderator
Post Reply