Hi,
I'm using the function below(from php.net - Mail functions), the problem appears if I use encoded subject, because in the encoded subject on every 76 chars there is \r\n, so
the line
fputs($connect, "Subject: $subject\r\n");
is problematic because if subject contains \n(when the subject is long) socketmail "thinks" that it's the end of the subject.
I have to encode the subject to include special characters in it.
If I use a regular mail function, then everything is ok, but I have to use socketmail to pass spam blocking.
Thanks in advance.
<?php
function socketmail($toArray, $subject, $message) {
// $toArray format --> array("Name1" => "address1", "Name2" => "address2", ...)
ini_set(sendmail_from, "myemail@address.com");
$connect = fsockopen (ini_get("SMTP"), ini_get("smtp_port"), $errno, $errstr, 30) or die("Could not talk to the sendmail server!");
$rcv = fgets($connect, 1024);
fputs($connect, "HELO {$_SERVER['SERVER_NAME']}\r\n");
$rcv = fgets($connect, 1024);
while (list($toKey, $toValue) = each($toArray)) {
fputs($connect, "MAIL FROM:myemail@address.com\r\n");
$rcv = fgets($connect, 1024);
fputs($connect, "RCPT TO:$toValue\r\n");
$rcv = fgets($connect, 1024);
fputs($connect, "DATA\r\n");
$rcv = fgets($connect, 1024);
fputs($connect, "Subject: $subject\r\n");
fputs($connect, "From: My Name <myemail@address.com>\r\n");
fputs($connect, "To: $toKey <$toValue>\r\n");
fputs($connect, "X-Sender: <myemail@address.com>\r\n");
fputs($connect, "Return-Path: <myemail@address.com>\r\n");
fputs($connect, "Errors-To: <myemail@address.com>\r\n");
fputs($connect, "X-Mailer: PHP\r\n");
fputs($connect, "X-Priority: 3\r\n");
fputs($connect, "Content-Type: text/plain; charset=iso-8859-1\r\n");
fputs($connect, "\r\n");
fputs($connect, stripslashes($message)." \r\n");
fputs($connect, ".\r\n");
$rcv = fgets($connect, 1024);
fputs($connect, "RSET\r\n");
$rcv = fgets($connect, 1024);
}
fputs ($connect, "QUIT\r\n");
$rcv = fgets ($connect, 1024);
fclose($connect);
ini_restore(sendmail_from);
}
?>