Using some code I found on one thread, I wrote an SMTP mailer. This is used with my local Exchange server, since messages through others means are not accepted. It hits our Exchange server and forwards a message. It works well, but with one problem: it adds about 9 seconds of code overhead per message. I'll post the code, and see if anyone has any ideas on what would make it run a little faster! Thanks!
function sendSMTP($recipient,$subject,$content) {
$smtp_server = "myserver";
$port = 25;
$mydomain = "mydomain.com";
$sender = "NO-REPLY@$mydomain";
$datesend = date("D M j G:i:s T Y");
$handle = fsockopen($smtp_server,$port);
if($handle) {
fputs($handle, "HELO $mydomain\r\n");
fgets($handle,100);
fputs($handle, "MAIL FROM:<$sender>\r\n");
fgets($handle,100);
fputs($handle, "RCPT TO:<$recipient>\r\n");
fgets($handle,100);
fputs($handle, "DATA\r\n");
fgets($handle,100);
fputs($handle, "From: VRS HelpDesk <$sender>\r\n");
fputs($handle, "To: $recipient\r\n");
fputs($handle, "Subject: $subject\r\n");
fputs($handle, "Date: $datesend\r\n");
fputs($handle, "Mime-Version: 1.0\r\n");
fputs($handle, "Content-Type: text/html; charset=\"iso-8859-1\"\r\n");
fputs($handle, "Content-Transfer-Encoding: 7bit\r\n");
fputs($handle, "This message is in MIME format. Since your mail reader does not understand\r\n");
fputs($handle, "this format, some or all of this message may not be legible.\r\n\r\n");
fputs($handle, "$content");
fputs($handle, "\r\n.\r\n");
fgets($handle,100);
fputs($handle, "QUIT\n");
fgets($handle,100);
sleep(5);
fclose($handle);
} else {
echo "Failed to open socket!";
}
}