I would like to send email with php mail function incuding a pdf attachment.
After playing around with it and several searches on google I am stuck. The
mail is delivered, and the attachment contains plain text (the message).
Maybe someone can give me a small hint. I guess it can't be that hard to
send an pdf attachment ??!!
Thanx,
Merlin
// send mail with attachment
function my_mail3($to,$subject,$message,$from){
$mailHeaders = "From: ".$from."\n"; // from
$mailHeaders .= "X-Mailer: PHP\n"; // mailer
$mailHeaders .= "Return-Path: <".$from.">\n"; // Return path for errors
$mailHeaders .= "MIME-Version: 1.0\r\n";
$mailHeaders .= "Content-Type: application/pdf; name=test.pdf;
Content-Disposition: attachment; Content-Transfer-Encoding:
quoted-printable\r\n";
#$headers .= "X-Attach my_file_path";
$body = $message;
if (mail($to, $subject, $body, $mailHeaders) ){
return true;
}
else{
return false;
};
}
http://pear.sourceforge.net/manual/core.mail.mime.php
addAttachment()
Adds an attachment to the email. It takes five arguments:
a.. $file - Either a filename or the actual file data itself.
b.. $c_type - Content type of the file. Defaults to
application/octet-stream if not given.
c.. $name - The filename of the file. Defaults to blank if not given.
d.. $isfilename - Whether the $file argument is a filename or not. If
true, the file will be read in Defaults to true if not given.
e.. $encoding - Type of transfer encoding to use for the file data.
Defaults to base64 if not given. for text based files (eg. scripts/html etc)
this could be given as quoted-printable.
Regards,
Peter "Pod" Pistorius
(Poor, unemployed, student in South Africa)
> I would like to send email with php mail function incuding a pdf
> attachment. After playing around with it and several searches on google I
> am stuck. The mail is delivered, and the attachment contains plain text
> (the message).
>
> Maybe someone can give me a small hint. I guess it can't be that hard to
> send an pdf attachment ??!!
archives > email attachment
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
If at first you fricasee, fry, fry again.
*/
Email with attachments and special types of content can be sent using this
function. This is accomplished via MIME-encoding - for more information, see
this (http://http://www.zend.com/zend/spotlight/sendmimeemailpart1.php)
article or the PEAR mime class.
I tryed the example in pear. Unfortunatelly one file seems missing.
mime.php:
SARATOGA:~ # ls /usr/local/lib/php/Mail/
RFC822.php sendmail.php smtp.php
Do I have to install a new version of pear? I remember that I have
previously send jpg images simply with php mail(), but cant find the code
anymore. Do I really need pear, and if so, do I have to upgrade? I am
running php 4.2.1
cheers,
merlin
"Peter Pistorius" <pet...@podbox.co.za> schrieb im Newsbeitrag
news:2003041714540...@pb1.pair.com...
function sendmsg($to, $subject, $text, $from, $file, $type) {
$content = fread(fopen($file,"r"),filesize($file));
$content = chunk_split(base64_encode($content));
$uid = strtoupper(md5(uniqid(time())));
$name = basename($file);
$header = "From: $from\nReply-To: $from\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=$uid\n";
$header .= "--$uid\n";
$header .= "Content-Type: text/plain\n";
$header .= "Content-Transfer-Encoding: 8bit\n\n";
$header .= "$text\n";
$header .= "--$uid\n";
$header .= "Content-Type: $type; name=\"$name\"\n";
$header .= "Content-Transfer-Encoding: base64\n";
$header .= "Content-Disposition: attachment;
filename=\"$name\"\n\n";
$header .= "$content\n";
$header .= "--$uid--";
mail($to, $subject, "", $header);
return true;
}
Thank You
Brian Paulson
Sr. Web Developer
Email: Bpau...@Chieftain.com
Phone: 1-800-279-6397
Fax: 1-719-544-0264
URL: www.chieftain.com
-------------------------------------------
Hi there,
Thanx,
Merlin
function my_mail3($to,$subject,$message,$from){
$body = $message;
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Give the command:
pear install Mail_Mime
I just installed this same class last week :-) pear will fetch it
automatically over the network. If you're behind a firewall, make sure
that you have $http_proxy and $ftp_proxy set.
--
mike
On 04/17/2003 11:48 AM, Merlin wrote:
> I would like to send email with php mail function incuding a pdf attachment.
> After playing around with it and several searches on google I am stuck. The
> mail is delivered, and the attachment contains plain text (the message).
>
> Maybe someone can give me a small hint. I guess it can't be that hard to
> send an pdf attachment ??!!
Try this class that lets you compose messages with attachments and more
very easily:
http://www.phpclasses.org/mimemessage
--
Regards,
Manuel Lemos
Mario Soto
mar...@amigo.net.gt
-.-.-.-