I would like to add a signature to the email, in html.
The signature is a variable ($end) so i don't know how i can send the correct version (html or plain text) as i will never know if the recipients mail client accepts html formatting.
- Code: Select all
// open this directory
$Ulocation = ("/website/test/email/upload/");
$myDirectory = opendir($Ulocation);
// get each entry into an array
while($entryName = readdir($myDirectory)) {
$files[] = $entryName;
}
$indexCount = count($files);
// email fields: to, from, subject, and so on
switch ($_POST['from']){
case "1":
$from=($_POST[other]);
break;
case "2":
$from="adam@website.co.uk";
$end="\r\n\r\n Adam \r\n\r\n nwww.website.co.uk | adam@website.co.uk";
break;
case "3":
$from="eve@website.co.uk";
$end="\r\n\r\n Eve \r\n\r\n www.website.co.uk | eve@website.co.uk";
break;
case "4":
$from="contact@website.co.uk";
$end="\r\n\r\n www.website.co.uk | contact@website.co.uk";
break;}
$to = $_POST['to'];
$cc = $_POST['cc'];
$bcc = $_POST['bcc'];
$subject = $_POST['subject'];
$message = stripslashes($_POST['message'].$end);
$headers = "From: $from" . "\r\n" .
$headers = "Cc: $cc" . "\r\n" .
$headers = "Bcc: $bcc";
// boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// headers for attachment
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
// multipart boundary
$message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
$message .= "--{$mime_boundary}\n";
// preparing attachments
for($index=2; $index < $indexCount; $index++) {
$file = fopen($Ulocation.$files[$index],"rb");
$data = fread($file,filesize($Ulocation.$files[$index]));
fclose($file);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$files[$index]\"\n" .
"Content-Disposition: attachment;\n" . " filename=\"$files[$index]\"\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
$message .= "--{$mime_boundary}\n";
}
closedir($myDirectory);
$ok = @mail($to, $subject, $message, $headers);
if ($ok){...
Here is what i'm thinking...
If i change the "content-type" to "multipart/alternative" then i get so confused.
If i made two signatures, $end and $End with one having the html formatting, then i can do it i think... i will try to do this myself (but that doesnt mean i don't want help, please god someone help me) and update any changes i come up with.


I never capitalise my i's except when it's the first word in a sentence, sorry.

though) but theres one niggling problem.