Revision: 15284
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 30, 2009 01:44 by cshaiku
Initial Code
#!/usr/local/bin/php <?php $to = $argv[1]; $subject = $argv[2]; $attachmentName = $argv[3]; $messageBoundry = md5(date('r', time())); $headers = "From: [email protected] Reply-To: [email protected]"; $headers .= " Content-Type: multipart/mixed; boundary=\"PHP-mixed-" . $messageBoundry . "\""; $attachment = chunk_split(base64_encode(file_get_contents($attachmentName))); ob_start(); //Turn on output buffering ?> --PHP-mixed-<?= $messageBoundry ?> Content-Type: multipart/alternative; boundary="PHP-alt-<?= $messageBoundry; ?>" --PHP-alt-<?=$messageBoundry?> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit --PHP-alt-<?= $messageBoundry ?> Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit <h3><?= $subject ?></h3> --PHP-alt-<?= $messageBoundry ?> <?= $subject ?> --PHP-mixed-<?= $messageBoundry ?> Content-Type: application/zip; name="<?= $attachmentName ?>" Content-Transfer-Encoding: base64 Content-Disposition: attachment <?= $attachment ?> --PHP-mixed-<?= $messageBoundry; ?> <?php $message = ob_get_clean(); mail( $to, $subject, $message, $headers ); ?>
Initial URL
http://code.cshaiku.com/code_php_email_attachment.php
Initial Description
Initial Title
Email Attachment
Initial Tags
email, Bash
Initial Language
PHP