Piping Email with PHP and SiteGround
One of the fun things to do with computers is to think outside the box, to use tools for things they aren’t exactly designed for. Email is one of my favorite toys with which to play with. Email is universal, and everyone has it. So when you create a new user for it, everyone can now do that.
What can we make email do that it doesn’t do already? Well, email is a delivery system, so we can use it to not only deliver data of some kind, but also to trigger an event that causes a computer somewhere to do something. If necessary, email can also respond back to you.
In the early days of the web, there were email addresses you could send an email to with a URL in the body. It would retrieve the URL and send you back the copy. Email pre-dated the web on the Internet, so there was a time when people had email but not web browser. This was a great way to get to the web before you got a web browser. The downside was that most email at that time didn’t support images, but this was okay because most webpages at this time didn’t HAVE images. 🙂
I’ve also used email to deliver data and trigger processing. Last year for Mother’s day, I built my mother and mother-in-law digital picture frames based on Raspberry Pis. The front-end media management for these frames is a WordPress site. This gave me a convenient API already built to deliver images to. The problem is that my siblings are not programmers, so I needed an easy way for them to send images to these frames. Email was that easy way.
I created a system that allows them to send a picture via email. Each digital picture frame has an email address, and they can send pictures to it. While WordPress handles all the user management and image processing, SiteGround’s email system allows me to make all of this happen.
The way to do this is called a “pipe” because you are “piping” the contents of an email to a program of your choosing.
I’ll stop here and tell you upfront that if you are not a programmer or at least a very technical user, this is not for you. Programmers can write programs (like I did) to take the input and process it. Technical users may also be able to install programs on their server that will accept the input and do something with it. If you are not in one of these two groups, I suggest you go find a programmer you trust and hire them to help you do this.
Comments ( 5 )
Thanks! Your comment will be held for moderation and will be shortly published, if it is related to this blog article. Comments for support inquiries or issues will not be published, if you have such please report it through
Morgan
A small PHP snippet would have been nice
Mke
Hey this sounds sweet, I second the request for a PHP snippet to get started. Perhaps a way to secure the process better would be to have a "secret code" typed into the email message body or append certain message subject? Just my thoughts.
Hristo Pandjarov Siteground Team
Could work just fine :) Depends on how you've setup your system.
Sean
The issue with a "secret code" included in an email is that it is not encrypted, is plainly visible and could be intercepted depending on how and where you are sending the email from. Email itself is not a secure format you can trust 100%. It is getting better though. Generally you can mostly trust an email it when it meets certain conditions. The bulk of the security comes into play with how you program your script(s).
dave
a "smart" secret code would help - something that changes based on the date/time or day or week or some combination. Not bulletproof, but a code that changes almost every time a message is sent would be that much more difficult to crack. The security issue doesn't seem all that important in this case ... some hacker sending photos to Mom's photo frame isn't going to wipe out her bank account.
Start discussion
Thanks! Your comment will be held for moderation and will be shortly published, if it is related to this blog article. Comments for support inquiries or issues will not be published, if you have such please report it through