I know I am missing something... but what ? (no sarcastic comments please 😃 )
take a look at this function
function socketmail($fromName, $fromAddress, $toArray, $subject, $message, $emailimage, $attachments, $logo, $sig, $unique) {
ini_set("sendmail_from", $fromAddress);
$handle = fsockopen ("192.168.150.5",25, $errno, $errstr, 30) or die("Could not talk to the sendmail server!<br/>$errno<br/>$errstr");
$rcv = fgets($handle, 1024);
fputs($handle, "HELO {$_SERVER['SERVER_NAME']}\r\n");
$rcv = fgets($handle, 1024);
while (list($toKey, $toValue) = each($toArray)) {
fputs($handle, "MAIL FROM:$fromAddress\r\n");
$rcv = fgets($handle, 1024);
fputs($handle, "RCPT TO:$toValue\r\n");
$rcv = fgets($handle, 1024);
fputs($handle, "DATA\r\n");
$rcv = fgets($handle, 1024);
fputs($handle, "Subject: $subject\r\n");
fputs($handle, "From: $fromName <$fromAddress>\r\n");
fputs($handle, "To: $toKey <$toValue>\r\n");
fputs($handle, "X-Sender: <$fromAddress>\r\n");
fputs($handle, "Return-Path: <$fromAddress>\r\n");
fputs($handle, "Errors-To: <$fromAddress>\r\n");
fputs($handle, "X-Mailer: PHP - SocketMail\r\n");
fputs($handle, "MIME-Version: 1.0\r\n");
fputs($handle, "X-Priority: 3\r\n");
fputs($handle, "Content-Type: multipart/mixed;\r\n");
fputs($handle, " boundary=\"----=_NextPart_000_000A_01C3EE3F.867B1730\"\r\n");
fputs($handle, "\r\n");
fputs($handle, "This is a multi-part message in MIME format.\r\n");
fputs($handle, "\r\n");
/*fputs($handle, "------=_NextPart_000_000A_01C3EE3F.867B1730\r\n");
fputs($handle, "Content-Type: text/plain;\r\n");
fputs($handle, " charset=\"ISO 8859-1\"\r\n");
fputs($handle, "Content-Transfer-Encoding: base64\r\n");
fputs($handle, "\r\n");
fputs($handle, chunk_split(base64_encode($message)) . "\r\n");
fputs($handle, "\r\n");
*/
fputs($handle, "------=_NextPart_000_000A_01C3EE3F.867B1730\r\n");
fputs($handle, "Content-Type: text/html;\r\n");
fputs($handle, " charset=\"ISO 8859-1\"\r\n");
fputs($handle, "Content-Transfer-Encoding: base64\r\n");
fputs($handle, "\r\n");
fputs($handle, chunk_split(base64_encode($message)) . "\r\n");
fputs($handle, "\r\n");
fputs($handle, "------=_NextPart_000_000A_01C3EE3F.867B1730--\r\n");
if (is_array($emailimage))
{
chdir("newsletters/mail_images");
$FILE = fopen(realpath("../mail_images")."/".$emailimage[1], "rb");
$content2 = fread($FILE, filesize(realpath("../mail_images")."/".$emailimage[1]));
fputs($handle, "Content-Type: ".$emailimage[0].";\r\n");
fputs($handle, "Content-Transfer-Encoding: base64\r\n");
fputs($handle, "Content-ID: image".$unique."\r\n");
fputs($handle, chunk_split(base64_encode($content2))."\r\n");
fputs($handle, "------=_NextPart_000_000A_01C3EE3F.867B1730--\r\n");
}
if (is_array($attachments))
{
chdir ("newsletters/attachments");
$FILE = fopen(realpath("../attachments")."/".$attachments[1], "rb");
$content2 = fread($FILE, filesize(realpath("../attachments")."/".$attachments[1]));
fputs($handle, "Content-Type: ".$attachments[0].";\r\n");
fputs($handle, " name=\"".$attachments[1]."\"\r\n");
fputs($handle, "Content-Transfer-Encoding: base64 \r\n");
fputs($handle, "Content-Disposition: attachment;\r\n");
fputs($handle, " filename=\"".$attachments[1]."\"\r\n");
fputs($handle, "Content-Transfer-Encoding: base64 \r\n");
fputs($handle, "\r\n");
fputs($handle, chunk_split(base64_encode($content2)));
fputs($handle, "\r\n");
fputs($handle, "------=_NextPart_000_000A_01C3EE3F.867B1730--\r\n");
}
fputs($handle, "\r\n");
fputs($handle, ".\r\n");
$rcv = fgets($handle, 1024);
fputs($handle, "RSET\r\n");
$rcv = fgets($handle, 1024);
}
fputs ($handle, "QUIT\r\n");
$rcv = fgets ($handle, 1024);
//echo("$rcv<br>");
fclose($handle);
ini_restore("sendmail_from");
}
I pass everything through - and the mail does get sent. Looking at the size of it i can tell that the images in either the attachments or as inline cid: images ae there - but they don't come out..
Anyone got any ideas ?
Thanks,