$length = 0;
if (isMultipart()) {
- reset($attachments);
- while (list($localname, $remotename) = each($attachments)) {
- // This is to make sure noone is giving a filename in another
- // directory
- $localname = ereg_replace ("\\/", '', $localname);
-
- $fileinfo = fopen ($attachment_dir.$localname.'.info', 'r');
- $filetype = fgets ($fileinfo, 8192);
- fclose ($fileinfo);
- $filetype = trim ($filetype);
- if ($filetype=='')
+ foreach ($attachments as $info)
+ {
+ $filetype = $info['type'];
+ if ($filetype == '')
$filetype = 'application/octet-stream';
$header = '--'.mimeBoundary()."\r\n";
- $header .= "Content-Type: $filetype;name=\"$remotename\"\r\n";
- $header .= "Content-Disposition: attachment; filename=\"$remotename\"\r\n";
+ $header .= "Content-Type: $filetype; name=\"" .
+ $info['remotefilename'] . "\"\r\n";
+ $header .= "Content-Disposition: attachment; filename=\"" .
+ $info['remotefilename'] . "\"\r\n";
$header .= "Content-Transfer-Encoding: base64\r\n\r\n";
fputs ($fp, $header);
$length += strlen($header);
- $file = fopen ($attachment_dir.$localname, 'r');
+ $file = fopen ($attachment_dir . $info['localfilename'], 'r');
while ($tmp = fread($file, 570)) {
$encoded = chunk_split(base64_encode($tmp));
$length += strlen($encoded);
errorCheck($tmp, $smtpConnection);
/** Ok, who is sending the message? */
- fputs($smtpConnection, "MAIL FROM:<$from_addr>\r\n");
+ fputs($smtpConnection, "MAIL FROM: <$from_addr>\r\n");
$tmp = fgets($smtpConnection, 1024);
errorCheck($tmp, $smtpConnection);
errorCheck($tmp, $smtpConnection);
}
for ($i = 0; $i < count($cc); $i++) {
- fputs($smtpConnection, "RCPT TO:<$cc[$i]>\r\n");
+ fputs($smtpConnection, "RCPT TO: $cc[$i]\r\n");
$tmp = fgets($smtpConnection, 1024);
errorCheck($tmp, $smtpConnection);
}
for ($i = 0; $i < count($bcc); $i++) {
- fputs($smtpConnection, "RCPT TO:<$bcc[$i]>\r\n");
+ fputs($smtpConnection, "RCPT TO: $bcc[$i]\r\n");
$tmp = fgets($smtpConnection, 1024);
errorCheck($tmp, $smtpConnection);
}
}
sqimap_logout($imap_stream);
// Delete the files uploaded for attaching (if any).
- deleteAttachments();
+ ClearAttachments();
}
?>