DownloadMail Plugin Question: Multiple email accounts

I have set up this plugin to download email from a POP3 account (newsletterarchives@) and automatically post the content to a newsletter page.

I have now added additional email accounts to the downloadmail.php file, designed to do the same with other sections (e.g. Calgary@, Edmonton@ - these are Chapters of my clients organization where I want to post event information via email.)

Here's where I'm stumped...how do I ensure that the correct emails get posted to the correct pages:

Newsletter to Newsletter archives page
Calgary events to Calgary page,
etc. without all emails getting posted to one section.

...or is it possible to do this?

Cheers,
Brian

Re: [affinitymc] DownloadMail Plugin Question: Multiple email accounts

By Jason - August 16, 2010

Hi,

So all of your emails are getting saved to the incoming_mail table, but you only want to extract certain emails on certain pages. Is that right?

What you can do is look at the "To" field in the table. For example, if you're trying to get all the emails sent to the "Calgary@" email address, your query could look like this:

list($calgaryEventsRecords,$calgaryEventsMetaData)=getRecords(array(
'tableName' => 'incoming_mail',
'where' => "to LIKE 'Calgary@%'",
));


This should only retrieve emails where the to field begins with Calgary@

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] DownloadMail Plugin Question: Multiple email accounts

By affinitymc - August 17, 2010 - edited: August 18, 2010

Thanks Jason,

I added the code above into the header of the calgary.php page, but am getting the following error:

MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near "to LIKE 'Calgary@%'") ORDER BY createdDate DESC' at line 3

Would you mind rechecking the code?

Thanks

Brian

Re: [affinitymc] DownloadMail Plugin Question: Multiple email accounts

By Jason - August 18, 2010

Hi,

Sorry about that. The word "to" is a reserved word in MySQL, we we need to change the code to this:

list($calgaryEventsRecords,$calgaryEventsMetaData)=getRecords(array(
'tableName' => '_incoming_mail',
'where' => "`to` LIKE 'Calgary@%'",
'debugSql' => true,
));


Hope that helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] DownloadMail Plugin Question: Multiple email accounts

Thanks Jason,
I'm now getting the following error:

Warning: Invalid argument supplied for foreach() in /homepages/19/d122429285/htdocs/agna/NewSite2010/calgary.php on line 140

Line 140 refers to the attachment upload:
<?php foreach ($_incoming_mailRecord['attachments'] as $upload): ?>

Re: [affinitymc] DownloadMail Plugin Question: Multiple email accounts

By Jason - August 18, 2010

Hi,

You can check to see if $_incoming_mailRecord['attachments'] is an array before you start, like this:

<?php if(is_array($_incoming_mailRecord['attachments'])): ?>
<?php foreach ($_incoming_mailRecord['attachments'] as $upload): ?>
*YOUR CODE*
<?php endforeach ?>
<?php endif ?>

---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [affinitymc] DownloadMail Plugin Question: Multiple email accounts

By Jason - August 18, 2010

Hi,

Please attach calgary.php and I can take a closer look.

Thanks,
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] DownloadMail Plugin Question: Multiple email accounts

Thanks Jason,
Here it is...
Attachments:

calgary.php 6K

Re: [affinitymc] DownloadMail Plugin Question: Multiple email accounts

By Jason - August 18, 2010

Hi,

Try replacing the code between lines 131 and 160 with this:

<?php foreach ($_incoming_mailRecords as $record): ?>

<?php echo $record['subject'] ?><br/>
<?php echo $record['text'] ?><br/>
<?php echo $record['html'] ?><br/>

<!-- STEP 2a: Display Uploads for field 'attachments' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->

<?php foreach ($record['attachments'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>

<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>

<?php endif ?>
<?php endforeach ?>
<!-- STEP2a: /Display Uploads -->
<?php endforeach ?>


<hr/>
<?php if (!$_incoming_mailRecords): ?>
No records were found!<br/><br/>
<?php endif ?>


Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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