They say you learn something new every day.

As much as I may hate it, sometimes you have to send eMail with code. Like democracy, eMail is the worst form of communication, except for all the others.

Each coding language has different ways of sending eMail. I had to send some messages with PHP today, so I put this little function together:

function send_email($from, $to, $subject, $message)
$headers = “From: “.$from.”\r\n”;
$headers .= “Reply-To: “.$from.”\r\n”;
$headers .= “Return-Path: “.$from.”\r\n”;
$headers .= “Content-type: text/html\r\n”;

It turns out you can’t use bcc in PHP (it’s blocked for security reasons, bizarrely). So when I wanted to bcc someone, I just had to call the same function twice with different email addresses.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Tag Cloud

%d bloggers like this: