Creating multipart email in PHP

Sending a simple and short email in PHP is an easy task. The following lines do just that ( )

// The message
$message = "Line 1\r\nLine 2\r\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70, "\r\n");

// Send
mail('', 'My Subject', $message);

However, sending a more involved email, including attachment and several MIME parts require some more code. Fortunately, this is not very complicated. Continue reading “Creating multipart email in PHP”