Jump to content
Pete

ProcessEmailToPage

Recommended Posts

Ok sorted it out to use the Username on the Emailadress field get it working....but the script holds on this error

Error: Call to a member function add() on a non-object (line 360 of /var/www/webxxx/html/rezepte/site/modules/ProcessEmailToPage/ProcessEmailToPage.module)

This error message was shown because you are logged in as a Superuser. Error has been logged. 

it's this lines:

// Iterate through any attachments if we have an images field for this page
if (isset($message['attachment'])) {
    foreach ($message['attachment'] as $attachment) {
        // We need to make the filename safe before continuing
        $attachment['filename'] = $this->sanitizer->pageName($attachment['filename'], true);
        // Write the file directly to the /files/pageid/ folder, then add it to ProcessWire (adds info to the DB)
        if(strlen($attachment['data'])>0){
            file_put_contents($page->images->path . $attachment['filename'], $attachment['data']);
            $page->images->add($page->images->path . $attachment['filename']);
        }
    }
    $page->save();
}

i''ve send a normal email via handy (no html header, footer, signature) with an image attachment....

regards mr-fan

Share this post


Link to post
Share on other sites

@mr-fan,

It looks like you are using my latest version of this module - I was playing around with attachments and embedding them into RTE fields. I think the error is coming from the images field. Does your page have an images field? Is it named "images"?

Share this post


Link to post
Share on other sites

....forgot top tell that i use the lastet version from here...

yes there is a imagefield but named "Bilder" .....is this hardcoded somewhere?

-> and yes until this line the script works and setup the page correctly!!

Thank and regards mr-fan

Share this post


Link to post
Share on other sites

Great - tested -> works....asap i will provide german translation and if some others test the new functions may update this version....looks really good!

Thank you adrian!

If needed i could send you one of the favorite recipes translated.....;)

  • Like 1

Share this post


Link to post
Share on other sites

@mr-fan - thanks for testing. I am not sure this module is getting a lot of use, so I am not expecting many others to test so maybe I'll just submit a PR to Pete to get this new version committed to Github and available from the modules directory.

Share this post


Link to post
Share on other sites

...i will test it with different mailprogs and settings....i find this is a very usefull addon!

but until now it works like a charm!

one thin would maybe a nice option....that may could easy done?

if some emailclient use html tags and u don't want them in the textarea just the clean text transmitted - is there a chance to get a flag for striptags? for the body field and the additional fields - could be a general setting, too.

This would provide more secure to get the content in a usable format.

Best Regards mr-fan

Share this post


Link to post
Share on other sites
if some emailclient use html tags and u don't want them in the textarea just the clean text transmitted - is there a chance to get a flag for striptags? for the body field and the additional fields - could be a general setting, too.

It already strips out all html tags except 

<br><br /><p><strong><b><a><img>

Although looking at this, it should probably be expanded to include <em> and maybe even <b> and <i>

Does this take care of your request, or is it something else I am not understanding? Or is the stripping of tags not working for you?

Share this post


Link to post
Share on other sites

Oh that explains some questions....i use many different textareas for testing - if i test modules i don't only break it down to just my usecase since i'm testing addons in my former cms for a long time and for many devs.

(making stupid userthings is one of my strenght - so i'm finding a way down to murphy's law.)

i used textareas with different markups like MarkDown and there i was getting tags that are allowed <br> and so on -> MarkDown isn' working korrekt there and show the tags in cleartext.

But this is a very special test/usecase.

i found the code for this - if someone read's this threat he could finaly set it for such usecases to get special results.

Thanks again for your work and response!

(while i'm testing new versions i'll learn a lot from the changes and i enjoy it since modules are written in a really easy way in processwire so that a php noob could understand OOP that simple make sence and isn't that hard or abstract anymore!!)

// Run it through ProcessWire's sanitizer for good measure - restricts only to basic HTML tags
if($this->embedImages == 'TRUE' && $category->imagesField != ''){
	$message_body = $this->sanitizer->textarea($message_body, array('allowableTags' => '<br><br /><p><strong><b><a><img>'));
}
else{
	$message_body = $this->sanitizer->textarea($message_body, array('allowableTags' => '<br><br /><p><strong><b><a>'));
}

Share this post


Link to post
Share on other sites

Great module, however I'm having a problem with attachments.  I have the original image field, however the attachments don't show up.

@Adrian, Is the fork that you are working on the same as what's published on the ProcessWire page for Process Email To Page?

Much Thanks to @Pete and @Adrian for working on this module. 

Share this post


Link to post
Share on other sites

Hi Charles,

I think my fork is well ahead on the attachment functionality. In my limited tests I think it was working in all situations, but I might have missed something - so many different things to consider with different email clients. Anyway, please test my version and let us know how it goes for you.

  • Like 1

Share this post


Link to post
Share on other sites

Adrian,

Your changes made the difference.  It works great now. Thanks a million.

Best Regards,

Charles

  • Like 1

Share this post


Link to post
Share on other sites

Is there a way to get some additional message header information (i.e the FROM Address and the email DATE) to show up and could possibly be mapped to a PW field?

Share this post


Link to post
Share on other sites

Is there a way to get some additional message header information (i.e the FROM Address and the email DATE) to show up and could possibly be mapped to a PW field?

This should be very easy to add. Sorry I don't have time in the next few days and so it will probably have to wait till the new year, but if you are in a hurry, take a look at:

http://flourishlib.com/docs/fMailbox

That shows what you need to add: "received" (date) and "from". If you decide to add this support before I get a chance to look into, please send me a PR :)

It seems like going forward, this module needs to be further configurable so you can decide what fields you want stored and which PW fields you want them added to.

  • Like 1

Share this post


Link to post
Share on other sites

Hi again - I have just committed an update to my fork that supports capturing the received date and the from address (actually I parsed out the name associated with the email address). Is that what you are looking for, or do you actually want the email address? If so, I might need to add an option to choose what is required.

Anyway, let me know if things work for you.

  • Like 1

Share this post


Link to post
Share on other sites

Adrian,

You are indeed a miracle worker and a very talented developer.  Thanks for updating this module!  The new changes are immediately useful and I owe you a depth of gratitude.

Best Regards,

Charles

  • Like 1

Share this post


Link to post
Share on other sites

I think you are way too kind, but I am very glad I could help out a little. Please let me know if you do need access to the from email address, rather than the name and I'll sort that out.

Share this post


Link to post
Share on other sites

Adrian,

From the limited testing I have done so far, it is giving me the email address.  I need to test from other email providers other than Yahoo to see what shows up.  Either way, this is more than what I had yesterday.

I believe that the more functionality that this module has (being able to map email metadata with actual PW fields), the better it will serve the diverse needs of the PW community.  I also hope we can get these changes merged with the published version on the PW website.

Thanks again, as you have made my day. 

Best Regards,

Charles

Share this post


Link to post
Share on other sites

Interesting - maybe the account you are sending from doesn't have a name in the from address field, eg: "John Smith" <john@example.com>

I think it would be great to be able to match up the sender with a PW user account, most likely via their email address. This is easy to do, I just don't know what most people would want and don't want to end up with too many config options. 

I am also not sure just how many people are actually using this module, especially given how effective the PW admin is on mobile devices.

Anyone else out there have any thoughts on this - are others using this module? Should it simply populate a text field with the sender's name/email address, or try to match up to a PW user account? I might need to do some testing of the returned data to see what is actually being returned and match if possible.

Share this post


Link to post
Share on other sites

Ok, I first had the From field mapped to a PW Email Field.   My Yahoo account has the email and name both mapped to my email address, hence that's why the email address showed up.  I then tested on Gmail and MSN and nothing showed up.  I then understood the problem and changed the PW field to a text field and then the name showed up when importing Yahoo, Gmail and MSN emails.

Operator error on my part.  The Name field works great.

Share this post


Link to post
Share on other sites

That makes sense - thanks for clarifying the reason for the email address actually being populated. I have just pushed another update that now has three separate options: name, email, user

The first two are obvious. The third one (user) needs to be pointed to a page field that has "user" as the template of selectable pages. Also, you might want to set Label Field to "name" rather than the default "title". When the page is created, this field will grab the user from the list of PW users based on the email address, which means you then have full access to all other fields in the user template. It also sets the created and modified users on the Settings tab to this user. This should make it pretty powerful for emailing in blog posts and the like.

I probably need to add some checks to deal with the email address not matching a PW user, but I'll wait for the next update for that.

Let me know how it works for you.

This is what the result looks like on the new page:

post-985-0-24194400-1419654832_thumb.png

post-985-0-65063700-1419657201_thumb.png

  • Like 1

Share this post


Link to post
Share on other sites

FYI, I had a problem with the body text not showing up.  I looked at your code and ended up doing a diff to see what was going on.  Somehow the following code was dropped from the update:

$page->{$category->bodyField} = $body;

I added this code to the recent update and then the body text showed up again.

post-756-0-98398500-1419658355_thumb.png

  • Like 1

Share this post


Link to post
Share on other sites

FYI, I had a problem with the body text not showing up.  I looked at your code and ended up doing a diff to see what was going on.  Somehow the following code was dropped from the update:

Oops - sorry about that - fixed that and added a couple of checks around the user detection.

I am thinking the next important addition is treating attached images differently to attached files.

  • Like 1

Share this post


Link to post
Share on other sites

I have just committed another update that has a separate field for attachments that are not images. An email can now contain both and they will be treated separately with images being embedded in the body text when appropriate, but keeping other file types only a "attachments" and stored in the selected files field.

  • Like 1

Share this post


Link to post
Share on other sites

I finally got around to do some thorough testing of the new capabilities.  I tested on Customized Email, Gmail, Yahoo and MSN (Outlook) and everything works great.

I especially like how you treated the attachments and split out the From and email address.  Thanks again for all of the enhancements.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By gebeer
      I am happy to present my new fieldtype FieldtypeImageFromPage. It is made up of 2 modules:
      Fieldtype Image Reference From Another Page is a Fieldtype that stores a reference to a single image from another page. The image can be selected with the associated Inputfield.
      Inputfield Select Image From Page is an Inputfield to select a single image from images on a predefined page and it's children.
      And there also is a helper module that takes care of cleanup tasks.
      This module evolved out of a discussion about my other Module FieldtypeImagePicker.  It caters for use cases where a set of images is being reused multiple times across a site. With this fieldtype these images can be administered through a chosen page. All images uploaded to that page will be available in the inputfield.
      When to use ?
      Let editors choose an image from a set of images that is being used site-wide. Ideal for images that are being re-used across the site.
      Suited for images that are used on multiple pages throughout the site (e.g. icons).
      Other than the native ProcessWire images field, the images here are not stored per page. Only references to images on another page are stored. This has several advantages:
      one central place to organize images when images change, you only have to update them in one place. All references will be updated, too. (Provided the name of the image that has changed stays the same) Features
      Images can be manipulated like native ProcessWire images (resizing, cropping etc.) Image names are fully searchable through the API Accidental image deletion is prevented. When you want to delete an image from one of the pages that hold your site-wide images, the module searches all pages that use that image. If any page contains a reference to the image you are trying to delete, deletion will be prevented. You will get an error message to help you edit those pages and remove references there before you can finally delete the image. How to install and setup
      Download and install this module like any other modules in ProcessWire Create a page in the page tree that will hold your images. This page's template must have an images field Upload some images to the page you created in step 2 Create a new field. As type choose 'Image Reference From Another Page'. Save the field. In 'Details' Tab of the field choose the page you created in step 2 Click Save button Choose the images field name for the field that holds your images (on page template from step 2) Click Save button again Choose whether you want to include child pages of page from step 2 to supply images Add the field to any template You are now ready to use the field View of the inputfield on the page edit screen:

      View of the field settings

      The module can be installed from this github repo. Some more info in the README there, too.
      In my tests it was fairly stable. After receiving your valued feedback, I will eventually add it to the modules directory.
      My ideas for further improvement:
      - add ajax loading of thumbnails
      Happy to hear your feedback!
       
    • By gebeer
      Although the PW backend is really intuitive, ever so often my clients need some assistance. Be it they are not so tech savvy or they are not working in the backend often.
      For those cases it is nice to make some help videos available to editors. This is what this module does.
      ProcessHelpVideos Module
      A Process module to display help videos for the ProcessWire CMS. It can be used to make help videos (screencasts) available to content editors.
      This module adds a 'Help Videos" section to the ProcessWire backend. The help videos are accessible through an automatically created page in the Admin page tree. You can add your help videos as pages in the page tree. The module adds a hidden page to the page tree that acts as parent page for the help video pages. All necessary fields and templates will be installed automatically. If there are already a CKEditor field and/or a file field for mp4 files installed in the system, the module will use those. Otherwise it will create the necessary fields. Also the necessary templates for the parent help videos page and it's children are created on module install. The module installs a permission process-helpvideos. Every user role that should have access to the help video section, needs this permission. I use the help video approach on quite a few production sites. It is stable so far and well received by site owners/editors. Up until now I installed required fields, templates and pages manually and then added the module. Now I added all this logic to the install method of the module and it should be ready to share.
      The module and further description on how to use it is available on github: https://github.com/gebeer/ProcessHelpVideos
      If you like to give it a try, I am happy to receive your comments/suggestions here.
    • By Robin S
      A module created in response to the topic here:
      Page List Select Multiple Quickly
      Modifies PageListSelectMultiple to allow you to select multiple pages without the tree closing every time you select a page.
      The screencast says it all:

       
      https://github.com/Toutouwai/PageListSelectMultipleQuickly
      https://modules.processwire.com/modules/page-list-select-multiple-quickly/
    • By gebeer
      Hello all,
      sharing my new module FieldtypeImagePicker. It provides a configurable input field for choosing any type of image from a predefined folder.
      The need for it came up because a client had a custom SVG icon set and I wanted the editors to be able to choose an icon in the page editor.
      It can also be used to offer a choice of images that are used site-wide without having to upload them to individual pages.
      There are no image manipulation methods like with the native PW image field.
      Module and full description can be found on github https://github.com/gebeer/FieldtypeImagePicker
      Kudos to @Martijn Geerts. I used his module FieldTypeSelectFile as a base to build upon.
      Here's how the input field looks like in the page editor:

      Hope it can be of use to someone.
      If you like to give it a try, I'm happy to hear your comments or suggestions for improvement. Eventually this will go in the module directory soon, too.
    • By bernhard
      @Sergio asked about the pdf creation process in the showcase thread about my 360° feedback/survey tool and so I went ahead and set my little pdf helper module to public.
      Description from PW Weekly:
       
      Modules Directory: https://modules.processwire.com/modules/rock-pdf/
      Download & Docs: https://github.com/BernhardBaumrock/RockPDF
       
      You can combine it easily with RockReplacer: 
      See also a little showcase of the RockPdf module in this thread:
       
×
×
  • Create New...