getFile('example.zip'); /** * Since we're sending a plain text email, * we only need to read in the text file. */ $text = $mail->getFile('example.txt'); /** * To set the text body of the email, we * are using the setText() function. This * is an alternative to the setHtml() function * which would obviously be inappropriate here. */ $mail->setText($text); /** * This is used to add an attachment to * the email. */ $mail->addAttachment($attachment, 'example.zip', 'application/zip'); /** * Sends the message. */ $mail->setFrom('Joe '); $result = $mail->send(array('"Richard" ')); echo $result ? 'Mail sent!' : 'Failed to send mail'; ?>