Email Forwarding Question

9 posts by 2 authors in: Forums > CMS Builder
Last Post: September 19, 2014   (RSS)

By gkornbluth - September 7, 2014

Hi All,

I’m back thinking about a simple email forwarding structure that I can implement through CMSB, and wondered If anyone had any ideas that they’ve tried and that have worked.

Ideally,  if a specific value appears in a text field of a member’s user record, then those member's email addresses are put into an array, and any email that is sent to say boardmembers@mydomain.com is automatically forwarded to the members who have boardmember as the value of the text field. Same for membership committee@mydomain.com and a bunch of other address/value combinations.

I’ve played with %LIKE and get nowhere.

I can get

// load records
  list($accountsRecords, $accountsMetaData) = getRecords(array(
    'tableName'   => 'accounts',
  ));
 

// get account emails
  $allAccounts  =  mysql_query_fetch_all_assoc("SELECT * FROM `{$TABLE_PREFIX}accounts` WHERE board_of_director_position_1");
  $allEmails = array_pluck($allAccounts, 'email');
  // showme($allEmails);

 showme($allEmails);  
      ?>

To list all the emails with a value in board_of_director_position_1, but when I try to filter by something like:

$allAccounts  =  mysql_query_fetch_all_assoc("SELECT * FROM `{$TABLE_PREFIX}accounts` WHERE board_of_director_position_1 = 'Treasurer' ");

I get a blank array, even though I know there’s a value of Treasurer in at least one record.

Once that’s working, I’m still not sure how to proceed with the actual forwarding of the emails.

Sorry to be so dense, but there it is...

Any thoughts,

Thanks,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By gkornbluth - September 9, 2014

Thanks Claire,

I'll give that a try tomorrow

Jerry

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By gkornbluth - September 12, 2014

Thanks Claire,

Sorry for the delay.

That worked.

I found that since I was pulling the "Treasurer" value from another table, I needed to put the record number into the string compare.

So,

$allAccounts  =  mysql_query_fetch_all_assoc("SELECT * FROM `{$TABLE_PREFIX}accounts` WHERE board_of_director_position_1 LIKE '%4%' ");

returned the correct array values.

Is there an easy way to reference the "Treasurer" label Value instead?

Thanks,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By claire - September 12, 2014

Hi Jerry

If you're storing a reference to a record in another table by record number, then you're really stuck with using that record number in the query. Changing things around to get a reference to the label instead isn't really all that easy here.

Make sure you change it to a plain integer comparison, seeing as you're not checking against a string here:

$allAccounts  =  mysql_query_fetch_all_assoc("SELECT * FROM `{$TABLE_PREFIX}accounts` WHERE board_of_director_position_1 = 4");

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By gkornbluth - September 12, 2014 - edited: September 12, 2014

Great advice...

Now I guess that I'll have to tackle the forwarding part of the question.

Any ideas where too start?

The email download plugin perhaps?

Thanks,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By claire - September 18, 2014

Depends on how you want to forward the emails.

You could set up an email template, use the email address list as a placeholder in the BCC field, and send it out that way?

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By gkornbluth - September 18, 2014 - edited: September 18, 2014

Hi Claire,

I'd like to set this up as simply as possible, very similar to email forwarding on a mail server.

All mail sent to a@mydomain.com (the domain that has an CMSB installation) gets forwarded to b@gmail.com and c@hotmail.com, and f@aol.com with no alterations.

All mail sent to b@mydiomain.com gets forwarded to d@aol.com and someone@gmail.com.

Etc,

I'm trying to make it easier for site managers to keep up with changing forwarding assignments from within CMSB instead of having to log into a mailserver.

Thanks

Jerry

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By claire - September 19, 2014

I'd say you'd want to use php-imap to get the emails, then use the native PHP mail function to resend them out to the different addresses set in CMSB.

https://code.google.com/p/php-imap/

Not sure if it's ideal, but it might be a good place to start.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/