ryan

Email Image Module

Recommended Posts

Send photos from your mobile phone to ProcessWire, from anywhere, on-the-fly. ProcessWire maintains a chronological gallery that you can simply email photos to. Works with any e-mail capable device, whether mobile phone, tablet or desktop.


 


How to Install


  1. Setup a new email address at your provider. This address should be dedicated to the purpose of this module. Make the address private and cryptic enough so as not to be obvious or discoverable by others.

  2. Place the files included with this module in /site/modules/EmailImage/

  3. In your admin, go to Modules > Check for new modules.

  4. Click Install for the EmailImage module.

  5. Complete all the settings it asks for, per the email you setup in step 1.

  6. Check the box to test your connection, and save.

 


How to Use


  1. Email an image to the address you configured. You can include multiple images if you like. 

  2. After waiting a minute or two, view the URL /email-images/ in your site. This is a page that was installed for you to display images.

  3. Repeat and enjoy. :)

 


How to Customize


 


While this module has everything working out-of-the-box, it is meant to be customized to your needs. For example:


  • You may want to move or rename the /email-images/ page somewhere else. The EmailImage module keeps track of this page ID, so it is perfectly fine to remove or rename it if you want to.

  • Take a look at the /site/templates/email-images.php template file. You may wish to replace it entirely with your own code, or you might build upon what's there, or use it as-is. But chances are you'll at least want to swap in your own header/footer to fit within your site's design.

  • Take a look at /site/modules/EmailImage/EmailImageRender.php. That file contains an example function used to render an image gallery. This is the one called upon by the template file you just looked at. You might copy and paste this function somewhere else into your own site, and modify it to suite your own markup needs. Just remember to name it something different!

Please post links to what you create in this thread. 


 


How to Uninstall


 


You can uninstall this module in the same way as any other module, by checking the box to "uninstall" from the module settings screen. But please note the following warning: When you uninstall, your system is returned to the state that it was in before this module was installed. Meaning, the EmailImage pages and images will be deleted. So please backup your images somewhere else if you want to lose them during uninstall. After uninstalling, you can safely remove this dir: /site/modules/EmailImage/, and you can remove the template file: /site/templates/email-images.php. 


  • Like 15

Share this post


Link to post
Share on other sites

Oh, very clever!

(I cant test it because my mobile does not take photos and cant email either!)

  • Like 1

Share this post


Link to post
Share on other sites

Thanks Horst, Ryan and Philipp. Great module added to the repository.

Processwire - connecting people.

Share this post


Link to post
Share on other sites
(I cant test it because my mobile does not take photos and cant email either!)

We say "mobile" because that's the area where this module is most likely to be useful. However, the module doesn't care what device or computer you email photos from. Aren't you inheriting an iPhone 3g pretty soon?

Share this post


Link to post
Share on other sites

In theory - but I am not sure when! 

I still miss my old sony Z5

I was just thinking, would it be possible to add a bit that defines a gallery? So you would create two - one with the "name" myphoto, and the other morephotos

and then on the email, immediately after an image, put either myphoto or morephotos.

The script reads that and accesses the right page.

If nothing is put (or it does not relate to a known gallery) it goes to which ever is the default.

EDIT: you could extend that for adding a caption too.

caption: my caption

Share this post


Link to post
Share on other sites

This is brilliant! Is there any way to make it only process emails that come from a particular account, or a whitelist of accounts?

I have some potential uses here, but security is a huge issue—just having the address be obscure may not pass the litmus test of my scrutinizers.

Well done all. This is very cool.

Share this post


Link to post
Share on other sites

Great module! You guys definately are not like Moose the Cat..

Share this post


Link to post
Share on other sites

Yes, you can definitely whitelist email addresses, and we highly recommend you do. The module configuration screen has a section where you can enter what email address are allowed to post. 

Keep in mind though that email addresses can be faked, so it's not a guarantee. Though I didn't specifically work with this part and Horst can provide better guidance on that. 

  • Like 1

Share this post


Link to post
Share on other sites

Hi Ryan, that's great. I'll test it out later today. 

Share this post


Link to post
Share on other sites

Nice, Ryan! Love the demo page too. About a year ago I hired a friend to write something like this--it's actually a script run via cron. It uses an email whitelist, and our local police department uses it to post press releases, daily logs, and other items to their website (I think it's like 3 or 4 separate addresses they can send to).

Share this post


Link to post
Share on other sites

Would be lovely if something like this would be possible as well:

---
name: 
test-article-123
---
body: 
Eros euismod, lectus alias. Voluptatum, vitae, gravida. Blanditiis, soluta fugiat platea donec! Suscipit augue lacinia mauris illo anim suscipit euismod quaerat egestas felis autem aenean sem tristique labore cras veniam integer dui eu quisque praesentium phasellus do aperiam dolores, amet, aliquet pariatur a litora sequi ipsum pariatur conubia! Voluptate deleniti, id scelerisque fusce vestibulum ab? Nemo harum condimentum posuere voluptatum.
---
somefield: 
a value
---

Share this post


Link to post
Share on other sites

Greetings,

Thanks Ryan!

This opens the door to some ideas that have come up in various forum discussions...

With this module, it seems we are getting close to being able to create pages of any kind by sending an e-mail with the right bits to our ProcessWire installation. 

Maybe along with each site, we could create e-mail templates with reserved spots like <<title>>, <<name>>, <<body>> and other fields.  Then (if I am on the right track) we just need a way to pick up whatever is in those reserved bits as variables in the page-creation process!

I've been using the ProcessWire API to create pages and this seems like a potential extension of that process.

Thanks,

Matthew

Share this post


Link to post
Share on other sites

Cool now I can finally use outlook to build websites.

  • Like 6

Share this post


Link to post
Share on other sites

"Why did that weird image get posted to my web page???"

"That must be your Outlook stationery background."  :lol:

  • Like 2

Share this post


Link to post
Share on other sites

I think that a module like this mainly provides value in sending a mobile photo to a web site. The reason for that is that many of these mobile phones have no file-upload capability (at least iOS doesn't). But they can send email. So this module actually solves a need and lets you do something you can't otherwise do.

Phillip identified the need and solved it by using Tumblr as an intermediary (since their app will pass through photos), which was a great idea. This module solves the need by using email as the intermediary--the one common thing available to all smart phones (and all credit to Horst and Phillip for the ideas). 

When we get into specifying other types of data and fields, like what's been mentioned above, it definitely sounds cool and interesting. But the reality is, we don't need email for that… we could just login to ProcessWire. We need email only because mobile phones can't upload files. I don't personally have a need to populate text fields from emails, but it's feasible someone could (like some of the things MarcC mentioned, for example). For that need, I think the approach taken in this module would be a good way to go, and perhaps this module could serve as a good starting point to build that capability, for anyone interested. 

  • Like 4

Share this post


Link to post
Share on other sites

Great points, Ryan. If there's one thing I learned from testing this with office staff, it's that you don't want to add too many features to an email-to-post setup. The "posting press releases" functionality we added was for attached documents only--should have clarified that.

(Edit: Although getting a return email receipt with a link to edit the page is cool too)

Share this post


Link to post
Share on other sites

Hello all! Getting to know Processwire and really liking it thus far. Running into some trouble with this module (I'm thinking it's more of a PHP thing). I'm using Servint as my host.

Receiving the following error on /email-images/ :

Error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 4903304 bytes) (line 319 of /home/biggame/public_html/site/modules/EmailImage-master/EmailImageAdaptor.php) 

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

Thanks,

Jason

Share this post


Link to post
Share on other sites

I think that you need to increase your memory size to PHP. Especially for anything that deals with images. I'm guessing you've got it set to 16m or 32m right now. And you probably want to bump it up to 128m or better yet 256m. You can set this in the php.ini via the memory_limit directive. On a ServInt server, I believe this is located in the file /usr/local/lib/php.ini. You'll have to restart Apache after making the change to php.ini. 

Share this post


Link to post
Share on other sites

Hi Jason,

as Ryan already said, there is not enough memory for PHP.

And for those who are on a shared (Apache)-server and have no access to a php.ini file: you can try to set this line into the (root) .htaccess file:

php_value memory_limit 256M
 

or if this won't work:

php_value memory_limit 128M
 

  • Like 1

Share this post


Link to post
Share on other sites

Fantastic, thanks guys, will do!

-Jason

Share this post


Link to post
Share on other sites

Hallo!
I've just tried the module and it's working like a charm.

The problem is that I'm expecting the email entries from more than one user and I need to know who sent the email...?
Is there a way to identify the sender somehow?

Please advise.

Best regards,
Mick

Share this post


Link to post
Share on other sites

Hi Mick,
 
i have done the pop3 stuff of the module but I don't know how to do the whole story of your question. But maybe there is help with some kind of dirty hack: The sender is identified as $from and to get it out there and into a pw page you may set it into the $BodyText (like e.g. $BodyText = "<|$from|>\n"). This way you later can extract it from the page body once the page is created. Or you may look into the modules file if there is a way to hook into it somewhere before the page get created.

btw: Do you know that there is also another module Process Email to Page. Maybe it supports what you need out of the box. (I don't know it, but there is a real chance it could be)

  • Like 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.