Categories
PHP

A PHP Mailer Class

UPDATE: Added application of the basename() function to the attached filenames to get the filenames only.


This php class lets you attach multiple files and send emails via Postfix without digging into the messy headers 😀

Example USE:

Happy Mailing! 😀

Categories
Python

Python: Sending a bunch of images as email attachments

Python is just beautiful! In my last post I mentioned how you can setup an email server. Now, here’s the code I use to send a bunch of images as attachments with my outgoing emails. This code snippet was taken from the Python manual. But unfortunately the code was not complete. So, I had to hack through it and configure it to suit my needs.

It currently reads the “images” directory and mails out the png files. But if you look at the codes, you’ll see that the codes can be easily changed to send other files as well 🙂

I love Python!

PS: I am looking for a good way to attach files using PHP. The way I found was messy! I know the huge PHP community certainly has something better to offer. I will post it as soon as I find it 🙂

Categories
Uncategorized

Setting Up Email Server on your PC

If you setup an email server on your PC, you can easily send unlimited emails with a custom “From” address 🙂 This is particularly helpful if you want to send emails programmatically for some reasons (I like to send unimportant emails and small attachments via Python).

To setup a mail server on Ubuntu, just install the “postfix” package:

Now you can send emails with php, python or even by typing codes on the terminal.

It was simple. Wasn’t it?