CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail »
  • Using IMAP2SOAP »
  • getting imap2soap to work with the current trunk (civicrm 2.1 svn)
Pages: [1] 2

Author Topic: getting imap2soap to work with the current trunk (civicrm 2.1 svn)  (Read 7960 times)

mathieu

  • Administrator
  • Ask me questions
  • *****
  • Posts: 620
  • Karma: 36
    • Work
  • CiviCRM version: 4.7
  • CMS version: Drupal
  • MySQL version: MariaDB 10
  • PHP version: 7
getting imap2soap to work with the current trunk (civicrm 2.1 svn)
May 28, 2008, 12:32:15 pm
Hi,

I have backported to an existing CiviCRM installation a patch [1] linked with CRM-2574 in order to have shorter VERP addresses in CiviMail. Since CRM-2574 changes the address of e-mails sent, e.g. they use "b.1.9.27.243c148ff9a0f4b0b4327c5a-mike=example.com@example.com" instead of "bounce.1.9.27.[...]".  This helps to create e-mail addresses which conform better to RFC2821, by not being more than 64 characters.

Now, since we use imap2soap, we also need to patch imap2soap to support this. I have made the following changes (below). Did I miss anything?

One thing I am not sure whether I am breaking something, is on the line detecting replies. I am not sure why the $dest uses a regexp for that case in particular.

Code: [Select]
--- imap2soap-2.1.pl-ORIG       2008-05-28 15:16:49.000000000 -0400
+++ imap2soap-2.1.pl    2008-05-28 15:21:49.000000000 -0400
@@ -280,7 +280,7 @@
     $attempt = 0;
 
     if (defined($hash)) {
-      if ($dest eq 'bounce') {          # i.e. this is a bounced message
+      if ($dest eq 'bounce' || $dest eq 'b') {          # i.e. this is a bounced message
         while (1) {
           $result =
             $soapClient->mailer_event_bounce($soapKey, $jobId, $qId,
@@ -303,7 +303,7 @@
           $imap->move("INBOX.Failed", $msg) or die "imap2soap: Could not move to Failed \n";
         }
 
-      } elsif ($dest =~ /.*reply.*/i) { # or it's a reply
+      } elsif ($dest =~ /.*reply.*/i || $dest eq 'r') { # or it's a reply
         while (1) {
           $result =
             $soapClient->mailer_event_reply($soapKey,
@@ -327,7 +327,7 @@
           $imap->move("INBOX.Failed", $msg) or die "imap2soap: Could not move to Failed \n";
         }
 
-      } elsif ($dest eq 'unsubscribe') { # or an unsubscription
+      } elsif ($dest eq 'unsubscribe' || $dest eq 'u') { # or an unsubscription
         while (1) {
           $result =
             $soapClient->mailer_event_unsubscribe($soapKey, $jobId, $qId, $hash);
@@ -348,7 +348,7 @@
           $imap->move("INBOX.Failed", $msg) or die "imap2soap: Could not move to Failed \n";
         }
 
-      } elsif ($dest eq 'confirm') {    # or an opt-in confirmation
+      } elsif ($dest eq 'confirm' || $dest eq 'c') {    # or an opt-in confirmation
         while (1) {
           $result =
             $soapClient->mailer_event_confirm($soapKey, $jobId, $qId, $hash);
@@ -369,7 +369,7 @@
           printf "CiviCRM: failed opt-in event: $verpInfo \n";
           $imap->move("INBOX.Failed", $msg) or die "imap2soap: Could not move to Failed \n";
         }
-      } elsif ($dest eq 'optOut') {     # or an opt-out
+      } elsif ($dest eq 'optOut' || $dest eq 'o') {     # or an opt-out
         while (1) {
           $result =
             $soapClient->mailer_event_domain_unsubscribe($soapKey, $jobId, $qId, $hash);
@@ -394,7 +394,7 @@
       my ($dest, $dId, $gId) =
         ($verpInfo =~ m/(\w+)\.(\d+).(\d+)\@.*/);
 
-      if ($dest eq 'subscribe') {       # it's a subscribe request
+      if ($dest eq 'subscribe' || $dest eq 's') {       # it's a subscribe request
         while (1) {
           $result =
             $soapClient->mailer_event_subscribe($soapKey, $from, $dId, $gId);

Thanks,
matt (bgm on #civicrm)
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

fen

  • I post frequently
  • ***
  • Posts: 216
  • Karma: 13
    • CivicActions
  • CiviCRM version: 3.3-4.3
  • CMS version: Drupal 6/7
  • MySQL version: 5.1/5.5
  • PHP version: 5.3/5.4
Re: getting imap2soap to work with the current trunk (civicrm 2.1 svn)
May 28, 2008, 01:47:35 pm
Hi Matt -

How do you distinguish between 'reply' and 'resubscribe' with a single letter?

Note that imap2soap-2.1.pl is an older version of imap2soap.  The preferred version pointed to by http://wiki.civicrm.org/confluence/display/CRMDOC/Alternative+configuration+with+imap2soap.pl+-+no+Amavis+or+root+access can be downloaded from https://svn.civicactions.net/repos/civicrm/scripts/

Assuming you work out the reply/resubscribe conflict, in addition to your changes you'd probably want something like this (untested):
Code: [Select]
--- imap2soap.pl (revision 1436)
+++ imap2soap.pl (working copy)
@@ -300,7 +300,8 @@
         junk($imap, $msg, "No To: header in message $n");
         next;
       }
-    unless ($to =~ m/^\s*<?(bounce|confirm|optout|reply|subscribe|unsubscribe|resubscribe)/i)
+    # look for (bounce|confirm|optout|reply|subscribe|unsubscribe|resubscribe)
+    unless ($to =~ m/^\s*<?(bcorsu)[a-z]*[\.-]\d+[\.-]\d+[\.-]\d+[\.-]/i)
       {
         junk($imap, $msg, "Not a CiviMail message $n -- To: $to");
         next;

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: getting imap2soap to work with the current trunk (civicrm 2.1 svn)
May 28, 2008, 05:03:36 pm

i'm currently using

r for reply
and re for resubscribe

if it makes the code easier we can switch to using e for resubscribe. i suspect resubscribe is not a very frequent operation

also with the new "getting rid of domain id" proposal (http://civicrm.org/blog/), reduces the size of the verp string by 2 more characters. so i think we are now quite safe with the 64 character limit for most cases (some ridiculously long email addresses / domain names will still trip us)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: getting imap2soap to work with the current trunk (civicrm 2.1 svn)
May 29, 2008, 02:56:28 am
Quote from: Donald Lobo on May 28, 2008, 05:03:36 pm
if it makes the code easier we can switch to using e for resubscribe.

It would make it symmetric and it would allow people to create an uniform regexp for all the actions (so that CiviMail-bound emails are routed together to some place, say, a distinct mailbox), so I’m for it.

Quote from: Donald Lobo on May 28, 2008, 05:03:36 pm
also with the new "getting rid of domain id" proposal (http://civicrm.org/blog/), reduces the size of the verp string by 2 more characters. so i think we are now quite safe with the 64 character limit for most cases (some ridiculously long email addresses / domain names will still trip us)

Note that the limit is for the local part of the email address – i.e., the stuff that comes before the @ – so if we get/got rid of VERP, we’re done in this regard.
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

cap10morgan

  • I post occasionally
  • **
  • Posts: 56
  • Karma: 9
Re: getting imap2soap to work with the current trunk (civicrm 2.1 svn)
September 22, 2008, 02:45:46 pm
Quote from: fen on May 28, 2008, 01:47:35 pm
Hi Matt -

How do you distinguish between 'reply' and 'resubscribe' with a single letter?

Note that imap2soap-2.1.pl is an older version of imap2soap.  The preferred version pointed to by http://wiki.civicrm.org/confluence/display/CRMDOC/Alternative+configuration+with+imap2soap.pl+-+no+Amavis+or+root+access can be downloaded from https://svn.civicactions.net/repos/civicrm/scripts/

Assuming you work out the reply/resubscribe conflict, in addition to your changes you'd probably want something like this (untested):
Code: [Select]
--- imap2soap.pl (revision 1436)
+++ imap2soap.pl (working copy)
@@ -300,7 +300,8 @@
         junk($imap, $msg, "No To: header in message $n");
         next;
       }
-    unless ($to =~ m/^\s*<?(bounce|confirm|optout|reply|subscribe|unsubscribe|resubscribe)/i)
+    # look for (bounce|confirm|optout|reply|subscribe|unsubscribe|resubscribe)
+    unless ($to =~ m/^\s*<?(bcorsu)[a-z]*[\.-]\d+[\.-]\d+[\.-]\d+[\.-]/i)
       {
         junk($imap, $msg, "Not a CiviMail message $n -- To: $to");
         next;

I'm having more luck with this patch:

Code: [Select]
--- imap2soap.pl.orig   2008-09-20 00:57:27.000000000 -0500
+++ imap2soap.pl        2008-09-22 16:43:23.000000000 -0500
@@ -300,7 +300,8 @@
         junk($imap, $msg, "No To: header in message $n");
         next;
       }
-    unless ($to =~ m/^\s*<*"?(bounce|confirm|optout|reply|subscribe|unsubscribe|resubscribe)/i)
+    # look for (bounce|confirm|optout|reply|subscribe|unsubscribe|resubscribe)
+    unless ($to =~ m/^\s*<?([bcorsu]|re)[\.-]\d+[\.-]\d+[\.-]\d+[\.-]/i)
       {
         junk($imap, $msg, "Not a CiviMail message $n -- To: $to");
         next;
@@ -355,7 +356,7 @@
 
     if (defined($hash))
       {
-        if ($dest eq 'bounce')          # i.e. this is a bounced message
+        if ($dest eq 'b')          # i.e. this is a bounced message
           {
             while (1) {
               $result =
@@ -381,7 +382,7 @@
                 or fatal "Could not move to Failed";
             }
           }
-        elsif ($dest =~ /.*reply.*/i)   # or it's a reply
+        elsif ($dest eq 'r')   # or it's a reply
           {
             unless ($replyto)
               {
@@ -412,7 +413,7 @@
                 or fatal "Could not move to Failed";
             }
           }
-        elsif ($dest eq 'unsubscribe')  # or an unsubscription
+        elsif ($dest eq 'u')  # or an unsubscription
           {
             while (1) {
               $result =
@@ -437,7 +438,7 @@
             }
 
           }
-        elsif ($dest eq 'resubscribe')  # or an unsubscription
+        elsif ($dest eq 're')  # or an unsubscription
           {
             while (1) {
               $result =
@@ -462,7 +463,7 @@
             }
 
           }
-        elsif ($dest eq 'confirm')      # or an opt-in confirmation
+        elsif ($dest eq 'c')      # or an opt-in confirmation
           {
             while (1) {
               $result =
@@ -487,7 +488,7 @@
                 or fatal "Could not move to Failed";
             }
           }
-        elsif ($dest eq 'optOut')       # or an opt-out
+        elsif ($dest eq 'o')       # or an opt-out
           {
             while (1) {
               $result =
@@ -516,7 +517,7 @@
       {
         my ($dest, $dId, $gId) = ($verpInfo =~ m/(\w+).(\d+).(\d+)\@.*/);
 
-        if ($dest && $dest eq 'subscribe')      # it's a subscribe request
+        if ($dest && $dest eq 's')      # it's a subscribe request
           {
             unless ($replyto)           # contains $from if no Reply-to
               {

clearlytechnical

  • Guest
Re: getting imap2soap to work with the current trunk (civicrm 2.1 svn)
September 25, 2008, 10:18:31 am
Captain!

Thank you. I see the change you made to accomodate the "re".

I also noticed you didn't use the "||" for the else statement. I think they were trying keep the script backward compatible. Was there a reason you opted not to use the "||"?

I bypassed the "Unless" to test the email so I could see what the script did if it did flag a Civic mail. It seems I am getting a 500 Internal error when it goes to process the email. Not sure if it's a rights issue, or script issue.

So I am going to try your script and see if I can get it to at least flag the mail as civic and not junk and if I still have issues, then I will return to share my findings so it might help others.

fen

  • I post frequently
  • ***
  • Posts: 216
  • Karma: 13
    • CivicActions
  • CiviCRM version: 3.3-4.3
  • CMS version: Drupal 6/7
  • MySQL version: 5.1/5.5
  • PHP version: 5.3/5.4
Re: getting imap2soap to work with the current trunk (civicrm 2.1 svn)
October 03, 2008, 06:25:41 am
Quote from: Donald Lobo on May 28, 2008, 05:03:36 pm
also with the new "getting rid of domain id" proposal (http://civicrm.org/blog/), reduces the size of the verp string by 2 more characters. so i think we are now quite safe with the 64 character limit for most cases (some ridiculously long email addresses / domain names will still trip us)

I missed this proposal and I couldn't find it in the link.  Is the domain id still with us?  I think it's useful, though I do understand that it creates more complexity...

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: getting imap2soap to work with the current trunk (civicrm 2.1 svn)
October 03, 2008, 06:41:15 am

the link is: http://civicrm.org/node/352

domain_id has been eliminated from the code in 2.1

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

fen

  • I post frequently
  • ***
  • Posts: 216
  • Karma: 13
    • CivicActions
  • CiviCRM version: 3.3-4.3
  • CMS version: Drupal 6/7
  • MySQL version: 5.1/5.5
  • PHP version: 5.3/5.4
Re: getting imap2soap to work with the current trunk (civicrm 2.1 svn)
October 03, 2008, 07:25:10 am
But it looks like the $domainId is still sent in the mail strings.  From http://fisheye.civicrm.org/browse/CiviCRM/trunk/tools/amavisd-new/amavisd-new-2.5.2/amavisd?r=14828 :
Code: [Select]
17631    my ($dest, $domainId, $jobId, $qId, $hash) =
17632        ($verpInfo =~ m/(\w+)\.(\d+)\.(\d+)\.(\d+)\.([0-9A-F]+)\@.*/i);

Correct?

fen

  • I post frequently
  • ***
  • Posts: 216
  • Karma: 13
    • CivicActions
  • CiviCRM version: 3.3-4.3
  • CMS version: Drupal 6/7
  • MySQL version: 5.1/5.5
  • PHP version: 5.3/5.4
Re: getting imap2soap to work with the current trunk (civicrm 2.1 svn)
October 03, 2008, 07:28:43 am
Assuming the answer to the above question is 'yes', I've just released a new imap2soap.pl that should be v2.1 compliant.  I still don't have a live site to test it on right now, though, so please - if someone can test it out and report back, I would greatly appreciate it.

See: https://svn.civicactions.net/repos/civicrm/scripts/imap2soap.pl

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: getting imap2soap to work with the current trunk (civicrm 2.1 svn)
October 03, 2008, 07:41:28 am

yes that is still being included. i suspect we'll elminate it in a 2.x / 3.x version

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

fen

  • I post frequently
  • ***
  • Posts: 216
  • Karma: 13
    • CivicActions
  • CiviCRM version: 3.3-4.3
  • CMS version: Drupal 6/7
  • MySQL version: 5.1/5.5
  • PHP version: 5.3/5.4
Re: getting imap2soap to work with the current trunk (civicrm 2.1 svn)
October 03, 2008, 09:39:47 pm
Quote from: fen on October 03, 2008, 07:28:43 am
I've just released a new imap2soap.pl that should be v2.1 compliant.  I still don't have a live site to test it on right now, though, so please - if someone can test it out and report back, I would greatly appreciate it.

See: https://svn.civicactions.net/repos/civicrm/scripts/imap2soap.pl

When initially posted, that version had a bug in the regex - please re-pull (VERSION = '20081004-0430')

I still haven't got confirmation that it is v2.1 compatible, but the version posted earlier today was not even v1.9 compatible. :(

fen

  • I post frequently
  • ***
  • Posts: 216
  • Karma: 13
    • CivicActions
  • CiviCRM version: 3.3-4.3
  • CMS version: Drupal 6/7
  • MySQL version: 5.1/5.5
  • PHP version: 5.3/5.4
Re: getting imap2soap to work with the current trunk (civicrm 2.1 svn)
October 03, 2008, 09:59:21 pm
Quote from: fen on October 03, 2008, 09:39:47 pm
Quote from: fen on October 03, 2008, 07:28:43 am
I've just released a new imap2soap.pl that should be v2.1 compliant.  I still don't have a live site to test it on right now, though, so please - if someone can test it out and report back, I would greatly appreciate it.

See: https://svn.civicactions.net/repos/civicrm/scripts/imap2soap.pl

When initially posted, that version had a bug in the regex - please re-pull (VERSION = '20081004-0430')

I still haven't got confirmation that it is v2.1 compatible, but the version posted earlier today was not even v1.9 compatible. :(

Correction: the version number is VERSION = '20081004-0455'

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: getting imap2soap to work with the current trunk (civicrm 2.1 svn)
October 04, 2008, 07:07:40 am
Quote from: fen on October 03, 2008, 07:25:10 am
But it looks like the $domainId is still sent in the mail strings.
[…]
Correct?

Correct for 2.1.

As I’ll be most probably touching this code early next week to add the support for plus-extended email addresses (so you can create a civimail@gmail.com account and get the example subscribe address of civicrm+s.7.69.hash@gmail.com ‘for free’), I might pull out domain ids along the way (from 2.2, of course).

I’ll keep you posted.
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: getting imap2soap to work with the current trunk (civicrm 2.1 svn)
October 16, 2008, 04:01:14 pm
Brave alpha-testers of the new return channel PHP processor, please check out this thread.
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail »
  • Using IMAP2SOAP »
  • getting imap2soap to work with the current trunk (civicrm 2.1 svn)

This forum was archived on 2017-11-26.