Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Fighting Recruiter Spam with PHP – Proof of Concept
Oct 03, 2016 @ 16:56:29

On the SitePoint PHP blog editor Bruno Skvorc has a new tutorial posted showing a possible way to "fight recruiting spam" in your inbox with the help of a little bit of PHP.

The biggest concern I have with modern email providers, is the fact that they are all quite bad at spam control. [...] I don’t mean the “Nigerian prince” type of spam, which is mostly blocked successfully (unless you’re using FastMail – they can’t even recognize those) but stuff that I’m really, really not interested in getting. Case in point, recruiter spam.

In this tutorial, we’ll get started with building a custom email processor which can read individual emails, run them through some predefined rules, and act on them. The end result will be very similar to what many providers offer out of the box, but it’ll lay the groundwork for more advanced aspects in future posts.

His example application will do things like: do keyword matching for recruiter-ish things and auto-reply (then delete the original) and purge emails sent after unsubscribing from the service. He builds out the example application on a Homestead Improved VM, coming pre-installed with the IMAP extension for PHP (used to access the user's inbox). He then installs the tedivm/fetch package for the PHP code and shows how to read the emails from your inbox. He uses the FastMail service so he walks through how to hook the script into that service using an "application password".

From there he develops the functionality of the application including:

  • pattern matching on the body contents for "recruiter-ish" terms
  • setting a "points" threshold for the number of matches
  • sending replies with Swiftmailer
  • whitelisting certain terms
  • moving the messages into an "auto-replied" folder so we know who the script talked to

All of the code you'll need is included in the post along with several screenshots that help to ensure you're on the right path.

tagged: recruiter spam inbox script autoreply tutorial imap

Link: https://www.sitepoint.com/fighting-recruiter-spam-with-php-proof-of-concept/

NetTuts.com:
Building Advanced Email Features With IMAP and PHP
Oct 21, 2014 @ 17:19:47

On the NetTuts.com site they've posted a tutorial showing you how to build advanced features with IMAP and PHP. He bases it on the SimplifyEmail project and incldues examples of three different features to get you started.

Analysis of my own email showed I was receiving email from more than 230 automated senders, far fewer actual people. I was tired of constructing filters in Gmail and filling in a myriad of unsubscribe forms. I wanted to have more control over managing my email and simplifying my life. Finally, this past year, I decided to build the features I needed. The result is Simplify Email (SE), a small web app you can host yourself which offers a variety of cool new email features all of which you can check out on the project website. The coolest thing about SE is that it's a platform for reading, analyzing, routing and managing your email - the possibilities abound. Simplify Email is essentially a programmable playground for "hacking" your own email.

His three examples show you how to:

  • Checking your inbox and filter messages
  • Implement a Whitelist challenge to unknown senders
  • Reporting unanswered email

Each of these comes with plenty of code examples, screenshots and output examples (as well as some places where you might need to change some SE configuration values).

tagged: advanced email imap tutorial feature simpleemail filter whitelist reporting

Link: http://code.tutsplus.com/tutorials/building-advanced-email-features-with-imap-and-php--cms-22059

PHPMaster.com:
Exploring PHP’s IMAP Library, Part 2
Oct 04, 2012 @ 15:36:22

PHPMaster.com has published the second part of their series taking you on a tour through PHP's IMAP extension and its use. In part one they introduced the extension and showed how to connect, get the folders/emails and view message contents. In this part they expand n that and show you how to work with the messages and attachments.

In the first part of this series I discussed how to connect to IMAP servers using PHP’s IMAP extension. In this part we’ll complete the series by discussing working with folders and reading email content. Let’s get started!

He shows how to work with the "flags" set on messages (read, unread, replied, etc) - pulling them from the server and using the imap_setflag_full function to set them. There's a quick mention of deleting messages with imap_delete/imap_expunge and a section on viewing and downloading the attachments to messages.

tagged: imap library extension tutorial series attachment flags delete

Link:

Sameer Borate's Blog:
Downloading Gmail attachments using PHP
May 08, 2012 @ 14:08:40

Sameer Borate has a quick tutorial posted to his site today about using PHP, specifically the IMAP functionality, to grab attachments off of emails from Gmail.

Automatically extracting attachments from Gmail can be important for reasons where you need to process the attached files periodically with a CRON job. Also it can be useful for automatically archiving important attachments. Below is a simple proof-of-concept plain PHP code, devoid of any object-oriented features that extracts attachments from your Gmail account. It uses PHPs imap extension to access the inbox.

His simple script opens an IMAP connection to the Gmail server and loops through your current emails (max of 16) and tries to find any that have attachments. It then extracts this part of the message, base64_decodes it, and saves the set of them to the local file system. You can download the source here.

tagged: gmail attachment tutorial download imap

Link:

PHPMaster.com:
Creating a Mobile Photo Blog, Part 1
Oct 06, 2011 @ 13:35:57

PHPMaster.com has started up a new series of tutorials today with part one of "Creating a Mobile Photo Blog". The set of tutorials will show you how to create a simple blogging tool that will upload images as submitted via an email address.

This is the first article in a two-part series in which I will show you how to create a photo blog as part of your personal website which you can update from your phone simply by sending an email. You’ll write a script to check the inbox of an email account for new messages using POP3; the script will extract the messages’ subject line, body text, and attachments and update a database accordingly. You can then pull the information from the database for display on your blog, in a sidebar, or however else you see fit.

The start with some of the security considerations you'll need to keep in mind when creating a script like this depending on how open you want it to be (like filtering based on the "From" email or sending an approval message before posting). Included in the post is the SQL to create their basic tables for posts, image details and the pending items. There's also a PHP class (POP3) that makes an IMAP connection to a remote server, authenticates as your account and fetches the latest messages along with their attachments. These are pulled with a quick script and displayed via a foreach.

Part two will get into more of the integration of the images and the approval technique prior to posting the images.

tagged: tutorial photo blog imap email approval

Link:

Reddit.com:
How do you test email when in development?
Aug 31, 2011 @ 17:58:53

In this recent post to Reddit, a question is asked that's an issue for many developers testing the email sending abilities of their applications - how can it be tested effectively without outside services flagging you as a possible spammer.

So how do you guys do it? My current solution is to just output the email template HTML straight to the browser, but this doesn't always work. [...] I have considered sending emails through to my GMail, but I run my tests quite often and I'm not sure Google would be too happy with the amount I send. [...] I'm sure there's a better way I can handle this without modifying my code too much. Suggestions appreciated.

Suggestions from the comments include:

  • a local SMTP/IMAP server configured to catch all emails being sent
  • Changing the address based on an environment flag
  • Using "@example.com"
  • Saving the email as a .msg file for later review

There's also suggestions of other Mac or Windows software to mimic the mail server like smtp4dev and MockStmp

tagged: test email recommendation server imap stmp windows osx

Link:

PHPBuilder.com:
Downloading and Parsing Gmail Messages in PHP
Sep 01, 2010 @ 14:21:04

New on PHPBuilder.com today there's a tutorial showing you how to download and parse messages from Google Mail. In their case it's grabbing and parsing submissions from a form.

Some friends of mine publish a literary journal that accepts submissions via email. At their request I wrote a script to download messages from the journal's Gmail account and do some simple parsing tasks. Most of the submissions are made using an HTML form and a corresponding mailer script on their website, so I knew the precise format of the incoming messages (see Figure 1). What I didn't know was how to access Gmail in PHP.

He tried out the libgmailer script first, but ran into roadblocks until he realized he could use something PHP already had - the imap functions. With these he shows how to make a connection to the Gmail servers, get the listing of messages and pull out the body for the one you want to parse.

tagged: gmail google mail parse imap tutorial

Link:

WebReference.com:
Build Your Own PHP Web Mailer
Aug 11, 2010 @ 15:56:49

On WebReference.com today there's a new tutorial about creating a PHP interface for sending and receiving emails directly from a mailer script.

In this tutorial you will learn how to create your own PHP Web mailer. You will learn the necessary steps for creating an email account and making connections to the server protocols for sending and receiving email. You also will get a listing of PHP commands that you can use to customize the Web mailer to your specifications.

The script makes manual connections to the servers instead of using something like mail and sends the raw commands to send via an SMTP server and fetch over a POP3 connection. There's also an example of making an IMAP connection and sending commands to get the current list of messages, current status and fetch the messages.

tagged: web mailer tutorial imap stmp pop3

Link:

SugarCRM Developers Blog:
Enabling IMAP support under OS X Leopard
Aug 28, 2008 @ 17:05:01

John Mertic passed along a note about a new post to the SugarCRM developers blog detailing how to enable IMAP support for PHP on an OS X machine.

With the release of Mac OS X 10.5 Leopard last fall, Apple (finally) included a modern version of PHP (currently version 5.2.6 as of this writing). [...] However, the default install of PHP that Apple included didn't include all of the available PHP extensions. Most notable is the IMAP extension, which is used in SugarCRM for the Campaigns and Emails modules. However you can build this extension and have it loaded dynamically, without affecting the rest of the default PHP install.

He shows where to get the packages and libraries you'll need to get the support working. The method involves building a shared module and including it to be loaded in your php.ini. This way it doesn't disrupt anything the current build has and you don't have to recompile everything over again.

tagged: imap support leopard osx shared module compile

Link:

PHP.net:
Update to PHP 5.2.6 Release (XSL & IMAP)
May 06, 2008 @ 13:49:05

The PHP group has made a two quick updates to the recent release of PHP 5.2.6 for the Windows users out there:

The Windows installers and archives were missing the XSL and IMAP extensions.

These updated packages can be downloaded from the Downloads page on PHP.net as usual (with each updated package having a note indicating the change).

tagged: xsl phpnet update imap extension windows installer

Link:


Trending Topics: