I am trying to send an email with an attachment.
The problem is the attachment is stored in db where I have created a
longblob field that contains the file so I have no idea how to specify
the file path when I want to send an email.
I have tried "" and "/" that didn't work.
Any help?
My code is
------------------------------------------------------------------------
$fileatt = ""; // Path to the file
$fileatt_type = "text/html"; // File Type
$fileatt_name = "AttachFilename .txt"; // Filename that will be used
for the file as the attachment
$email_from = ""; // Who the email is from
$email_subject = "Testing"; // The Subject of the email
$email_txt = "how are you?"; // Message that the email has in it
$message_text = ""; // Message that the email has in it
$email_to = ""; // Who the email is too
$headers = "From: ".$email_fr om;
$file = fopen($fileatt, 'rb');
$data = fread($file,fil esize($fileatt) );
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Bo undary_x{$semi_ rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mi me_boundary}\"" ;
$email_message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary }\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message_text . "\n\n";
$data = chunk_split(bas e64_encode($dat a));
$email_message .= "--{$mime_boundary }\n" .
"Content-Type: {$fileatt_type} ;\n" .
" name=\"{$fileat t_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fi leatt_name}\"\n " .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary }--\n";
$ok = @mail($email_to , $email_subject, $email_message, $headers);
-------------------------------------------------------------------------
Thanks a lot in advance,
The problem is the attachment is stored in db where I have created a
longblob field that contains the file so I have no idea how to specify
the file path when I want to send an email.
I have tried "" and "/" that didn't work.
Any help?
My code is
------------------------------------------------------------------------
$fileatt = ""; // Path to the file
$fileatt_type = "text/html"; // File Type
$fileatt_name = "AttachFilename .txt"; // Filename that will be used
for the file as the attachment
$email_from = ""; // Who the email is from
$email_subject = "Testing"; // The Subject of the email
$email_txt = "how are you?"; // Message that the email has in it
$message_text = ""; // Message that the email has in it
$email_to = ""; // Who the email is too
$headers = "From: ".$email_fr om;
$file = fopen($fileatt, 'rb');
$data = fread($file,fil esize($fileatt) );
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Bo undary_x{$semi_ rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mi me_boundary}\"" ;
$email_message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary }\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message_text . "\n\n";
$data = chunk_split(bas e64_encode($dat a));
$email_message .= "--{$mime_boundary }\n" .
"Content-Type: {$fileatt_type} ;\n" .
" name=\"{$fileat t_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fi leatt_name}\"\n " .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary }--\n";
$ok = @mail($email_to , $email_subject, $email_message, $headers);
-------------------------------------------------------------------------
Thanks a lot in advance,
Comment