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 eelkenet
      Hi! I've created a small Inputfield module called InputfieldFloatRange which allows you to use an HTML5 <input type="range" ../> slider as an InputField. I needed something like this for a project where the client needs to be able to tweak this value more based on 'a feeling' than just entering a boring old number. Maybe more people can use this so I'm hereby releasing it into the wild. 
      EDIT: You can now install it directly from the Modules directory: http://modules.processwire.com/modules/inputfield-float-range/
       
      What is it?
      The missing range slider Inputfield for Processwire. 
      What does it do?
      This module extends InputfieldFloat and allows you to use HTML5 range sliders for number fields in your templates.
      It includes a visible and editable value field, to override/tweak the value if required.  
      Features
      Min/max values Precision (number of decimals) Optional step value (Read more) Optional manual override of the selected value (will still adhere to the rules above) Configurable rounding of manually entered values (floor, round, ceil, disable) Usage
      Clone / zip repo Install FieldtypeFloatRange, this automatically installs the Inputfield Create new field of type `Float (range)` or convert an existing `Float`, `Integer` or `Text` field. To render the field's value simply echo `$page->field` Demo
      A field with Min=0, Max=1, Step=0.2, Precision=2

      Field with settings Min=0, Max=200, Step=0.25, Precision=2

       
      Todo
      Make the display-field's size configurable (will use the Input Size field setting)  Hopefully become redundant  
      Changelog
      004 (current version)
      - Make rounding of manually entered values configurable (floor, round, ceil or disable)
      - Fix small JS bug when the value-display field was not displayed
      - Update README
      003
      - Code cleanup, add some ModuleInfo data & LICENSE
      - Submit to PW Modules directory (http://modules.processwire.com/modules/inputfield-float-range/)
      002
      - Fix issue where setting the step value to an empty value created problem with validation
      - Make the display-field optional
      001
      - Initial release
       
      Thanks!
       
       
    • By Gadgetto
      Status update links (inside this thread) for SnipWire development will be always posted here:
      2019-10-18
      2019-08-08
      2019-06-15
      2019-06-02
      2019-05-25
      If you are interested, you can test the current state of development:
      https://github.com/gadgetto/SnipWire
      Please note that the software is not yet intended for use in a production system (alpha version).
      If you like, you can also submit feature requests and suggestions for improvement. I also accept pull requests.
      ---- INITIAL POST FROM 2019-05-25 ----
      I wanted to let you know that I am currently working on a new ProcessWire module that fully integrates the Snipcart Shopping Cart System into ProcessWire. (this is a customer project, so I had to postpone the development of my other module GroupMailer).
      The new module SnipWire offers full integration of the Snipcart Shopping Cart System into ProcessWire.
      Here are some highlights:
      simple setup with (optional) pre-installed templates, product fields, sample products (quasi a complete shop system to get started immediately) store dashboard with all data from the snipcart system (no change to the snipcart dashboard itself required) Integrated REST API for controlling and querying snipcart data webhooks to trigger events from Snipcart (new order, new customer, etc.) multi currency support self-defined/configurable tax rates etc. Development is already well advanced and I plan to release the module in the next 2-3 months.
      I'm not sure yet if this will be a "Pro" module or if it will be made available for free.
      I would be grateful for suggestions and hints!
      (please have a look at the screenshots to get an idea what I'm talking about)
       




    • By Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. Field widths entered into the Template Field Widths inputfield are only applied if the Edit Template form is submitted with the Template Field Widths inputfield in an opened state. "Collapsed" is the recommended setting if you think you might also use core inputs for setting field widths in a template context. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/
    • By adrian
      Tracy Debugger for ProcessWire
      The ultimate “swiss army knife” debugging and development tool for the ProcessWire CMF/CMS

       
      Integrates and extends Nette's Tracy debugging tool and adds 35+ custom tools designed for effective ProcessWire debugging and lightning fast development
      The most comprehensive set of instructions and examples is available at: https://adrianbj.github.io/TracyDebugger
      Modules Directory: http://modules.processwire.com/modules/tracy-debugger/
      Github: https://github.com/adrianbj/TracyDebugger
      A big thanks to @tpr for introducing me to Tracy and for the idea for this module and for significant feedback, testing, and feature suggestions.
×
×
  • Create New...