\r\n"); $ret = server_parse($socket, "250"); if ($ret) { return $ret; } // Add an additional bit of error checking to the To field. $to = (trim($to) == '') ? 'Undisclosed-recipients:;' : trim($to); if (preg_match('#[^ ]+\@[^ ]+#', $to)) { fputs($socket, "RCPT TO: <$to>\r\n"); $ret = server_parse($socket, "250"); if ($ret) { return $ret; } } // Ok now do the CC and BCC fields... foreach (array_merge($cc, $bcc) as $address) { $address = trim($address); if (preg_match('#[^ ]+\@[^ ]+#', $address)) { fputs($socket, "RCPT TO: <$address>\r\n"); $ret = server_parse($socket, "250"); if ($ret) { return $ret; } } } // Ok now we tell the server we are ready to start sending data fputs($socket, "DATA\r\n"); // This is the last response code we look for until the end of the message. $ret = server_parse($socket, "354"); if ($ret) { return $ret; } // Send the Subject Line... fputs($socket, "Subject: $subject\r\n"); // Now the To Header. fputs($socket, "To: $to\r\n"); // Now any custom headers.... if (isset($headers)) { fputs($socket, "$headers\r\n"); } // Ok now we are ready for the message... fputs($socket, "\r\n$body\r\n"); // Ok the all the ingredients are mixed in let's cook this puppy... fputs($socket, ".\r\n"); $ret = server_parse($socket, "250"); if ($ret) { return $ret; } // Now tell the server we are done and close the socket... fputs($socket, "QUIT\r\n"); fclose($socket); return null; } ?>