How can I subscribe to more mailinglist with double-opt-in?

Use this forum for questions regarding adoption and functionality of OpenEMM

Moderator: moderator

xpkiller
Posts: 4
Joined: Tue Nov 03, 2009 4:28 pm
Location: Hungary, Nyaregyhaza

How can I subscribe to more mailinglist with double-opt-in?

Post by xpkiller »

Hi,

I have a problem.
I want to use double-opt-in but I can allowe for users to select from mailinglists more than one.
Well if I create froms and actions I have to create action based mail and there I have to select a mailinglist name.
How can I create a from with a lot of mailinglist selectable with double-opt-in?

Thanks your help!

Regards,
Peter
xpkiller
Posts: 4
Joined: Tue Nov 03, 2009 4:28 pm
Location: Hungary, Nyaregyhaza

Post by xpkiller »

Nothing answer..
then I have to create forms, actions, mails separately for all mailinglist.
maschoff
Site Admin
Posts: 2628
Joined: Thu Aug 03, 2006 10:20 am
Location: Munich, Germany
Contact:

Post by maschoff »

We have written a script action for our commercial product EMM, but I am not sure if it works with OpenEMM as well. If you like I can post instructions and code here.
OpenEMM Maintainer
xpkiller
Posts: 4
Joined: Tue Nov 03, 2009 4:28 pm
Location: Hungary, Nyaregyhaza

Post by xpkiller »

If possible, I would see instruction and code.
May be help me.

Thank you!

(email: xpkiller-at-freemail-dot-hu)
maschoff
Site Admin
Posts: 2628
Joined: Thu Aug 03, 2006 10:20 am
Location: Munich, Germany
Contact:

Post by maschoff »

Ok, I will split this post since it is rather big:

Topic: Subscription to several maillists via one form

subscription form "subscribe-form.html":

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
   <title>Multiple Subscribe</title>
<script language="javascript" type="text/javascript">
<!--
function chkFormular()
{
 if(document.mailform.EMAIL.value.indexOf('@') == -1) {
   alert("Please enter a valid email address!");
   document.mailform.EMAIL.focus();
   return false;
  }
 if(document.mailform.agnSUBSCRIBE1.checked == false && document.mailform.agnSUBSCRIBE2.checked == false) {
    alert("Please select a maillist.");
    return false;
  }
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF">
<form action="#" method="post" name="mailform" onSubmit="return chkFormular()">
<input type="hidden" value="1" name="agnCI">
<input type="hidden" value="testform" name="agnFN">
<input type="hidden" value="2" name="GENDER">
<input type="hidden" value="1" name="MAILTYPE">
<input type="hidden" value="1" name="agnMAILINGLIST1">
<input type="hidden" value="2" name="agnMAILINGLIST2">
<input type="text" value="" name="EMAIL">Email<br><br><br>
<input type="checkbox" name="agnSUBSCRIBE1" value="1">Maillist 1<br>
<input type="checkbox" name="agnSUBSCRIBE2" value="1">Maillist 2<br><br>
<input type="submit">
</body>
</html>
OpenEMM Maintainer
maschoff
Site Admin
Posts: 2628
Joined: Thu Aug 03, 2006 10:20 am
Location: Munich, Germany
Contact:

Post by maschoff »

EMM form "testform" which is triggered by the web form of subscribe-form.html starts an action which steps

1. Subscribe (use double-opt-in, check for duplicates, key column "email")
2. Load recipient data
3. Script action

Code for script action:

Code: Select all

#set ($send = "0")

## maillist 1
$BindingEntry.setMailinglistID(1)
$BindingEntry.setCustomerID($customerID)

#if($BindingEntry.getUserBindingFromDB(1) == true)
   #if($BindingEntry.getUserStatus() == 5)
      #if ($send == "0")
         #set ($mail=$MailingDao.getMailing(XXXXXX, 1))
            #if($mail)
               $mail.sendEventMailing($customerID.intValue(), 0, "5", null, $ScriptHelper.getApplicationContext())
            #set ($send = "1")
      #end
   #end
#end

## maillist 2
$BindingEntry.setMailinglistID(2)
$BindingEntry.setCustomerID($customerID)

#if($BindingEntry.getUserBindingFromDB(1) == true)
   #if($BindingEntry.getUserStatus() == 5)
      #if ($send == "0")
         #set ($mail=$MailingDao.getMailing(XXXXXX, 1))
            #if($mail)
               $mail.sendEventMailing($customerID.intValue(), 0, "5", null, $ScriptHelper.getApplicationContext())
            #set ($send = "1")
      #end
   #end
#end

#set($scriptResult = "1")
where MailinglistID probably have to be adjusted (if not 1 and 2) and XXXXX is the mailingID of the double-opt-in mail for the corresponding maillist.

This script checks for every maillist whether the recipient is on this maillist with user_status 5 (="wait for confirm"). If so, it triggers the sending of the double-opt-in mail. Furthermore, it checks if the recipient already got a mail. If this is the case the following maillist(s) is/are ignored, because one mail is enough to subscribe to all selected maillists.
Last edited by maschoff on Wed Nov 11, 2009 1:33 pm, edited 2 times in total.
OpenEMM Maintainer
maschoff
Site Admin
Posts: 2628
Joined: Thu Aug 03, 2006 10:20 am
Location: Munich, Germany
Contact:

Post by maschoff »

If the recipient clicks on the confirmation link in the double-op-in mail (all double-opt-in mails may use the same link) an EMM form has to be called which triggers another script action:

Code: Select all

## Maillist 1
$BindingEntry.setMailinglistID(1)
$BindingEntry.setCustomerID($customerID)

#if($BindingEntry.getUserBindingFromDB(1) == true)
   #if($BindingEntry.getUserStatus() == 5)
        $BindingEntry.setUserStatus(1)
        $BindingEntry.setUserRemark("Opt-in by User")
        $BindingEntry.updateStatusInDB(1)
   #end
#end

## Maillist 2
$BindingEntry.setMailinglistID(2)
$BindingEntry.setCustomerID($customerID)

#if($BindingEntry.getUserBindingFromDB(1) == true)
   #if($BindingEntry.getUserStatus() == 5)
        $BindingEntry.setUserStatus(1)
        $BindingEntry.setUserRemark("Opt-in by User")
        $BindingEntry.updateStatusInDB(1)
   #end
#end

#set($scriptResult = "1")
where MailinglistID probably has to be adjusted again.

This script checks the given maillists and sets user_status to 1 ("active") if the recipient exists and has user_status 5.
Last edited by maschoff on Wed Nov 11, 2009 1:48 pm, edited 2 times in total.
OpenEMM Maintainer
maschoff
Site Admin
Posts: 2628
Joined: Thu Aug 03, 2006 10:20 am
Location: Munich, Germany
Contact:

Post by maschoff »

As a bonus script action for unscubscribe-confirm page:

Code: Select all

## Mailingliste 1
$BindingEntry.setMailinglistID(1)
$BindingEntry.setCustomerID($customerID)

#if($BindingEntry.getUserBindingFromDB(1) == true)
   #if($BindingEntry.getUserStatus() == 1)
        $BindingEntry.setUserStatus(4)
        $BindingEntry.setUserRemark("Opt-out by User")
        $BindingEntry.updateStatusInDB(1)
   #end
#end

## Mailingliste 2
$BindingEntry.setMailinglistID(2)
$BindingEntry.setCustomerID($customerID)

#if($BindingEntry.getUserBindingFromDB(1) == true)
   #if($BindingEntry.getUserStatus() == 1)
        $BindingEntry.setUserStatus(4)
        $BindingEntry.setUserRemark("Opt-out by User")
        $BindingEntry.updateStatusInDB(1)
   #end
#end

#set($scriptResult = "1")
This script checks for every maillist if binding exists and if status is active. If so, recipient is unsubscribed.
OpenEMM Maintainer
xpkiller
Posts: 4
Joined: Tue Nov 03, 2009 4:28 pm
Location: Hungary, Nyaregyhaza

Post by xpkiller »

Unfortunately it is not working for me :(
I cannot check your script because it is chinese for me. I'm a php and perl developer and I don't understand your script therefore I was able to copy/paste only but it says "error".
I have seen registration is started in database but it haven't sent any email for user.
Post Reply