Jay's Devlog

On coding, creation, and Internet culture

  • About

Structured Email Handling

Posted by jayferrando on April 12, 2012
Posted in: Coding. Tagged: email, mail, php. Leave a comment

It started with a simple requirement: A project I’m working on needed to send email with attachments.  Now, I could’ve just rigged something up to get the job done, but I’d just drank a NOS and I was feeling adventurous.

What I would up with is an EmailHandler class with a couple added features that will make handling email in project moving forward a whole lot easier and cleaner than with a few variables and php’s mail() function.  This little beast covers a few important things:

  • Multiple Attachments
  • Dual-Type mail: HTML support with fallback to plain-text if the recipient’s email client doesn’t support HTML mail
  • Submission either directy to php mail() or to a mailer queue db table for bulk mailing.
  • A clean, structured interface.

Alright, here’s the goods:

http://pastebin.com/qQTpdG8a

Note: You can see in the queue() method I’m using a non-standard db interface. You’ll probably want to tweak that func to work with your code.
So pretty straightforward, right?  Here’s a quick example covering most of the features:

http://pastebin.com/jYnFK118

And that’s all there is to it.

echo “Hello, World!”;

Posted by jayferrando on April 12, 2012
Posted in: Uncategorized. Leave a comment

So, where to begin.  I decided to start up a new blog since that’s the thing we apparently do these days.  From time to time I’ve got news on current projects, or neat little snippets of code I’d like to share with my colleagues, and I figure there’s a chance other people could make decent use of some of this info as well.

A little bit about myself.  I’m a web developer, I work predominantly with PHP/MySQL, and it goes without saying that I’ve got a pretty adept knowledge of HTML/CSS/JavaScript as well.  Most of the work I do involves building back-end systems, or frameworks to develop back-end systems; I suppose I just like to find a way to make things tick rather than building on top of something that’s already ticking.  I’m pretty typical as far as young guys that work for a start-up: College student by day, webdev extraordinaire by night.  Fueled mostly by energy drinks and ramen.  A little but socially awkward, and very, very eccentric.

It also goes without saying that I’m a pretty huge dork, so in addition to coding-related stuff, I’ll likely also post entertaining stuff of the nerdy variety. Whoopie.

Posts navigation

  • Recent Posts

    • Structured Email Handling
    • echo “Hello, World!”;
  • Archives

    • April 2012
  • Categories

    • Coding
    • Uncategorized
  • Meta

    • Create account
    • Log in
    • Entries feed
    • Comments feed
    • WordPress.com
Blog at WordPress.com.
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Subscribe Subscribed
    Jay's Devlog

    Have a WordPress.com account? Log in now.

  • Jay's Devlog
    View site in Reader
    Manage subscriptionsSign upLog in
    Report this content
    Collapse this bar
Create your own website, free on WordPress.com.Create your own website.
Start free