function smtp_mail($to, $from, $data) { global $CONF; $smtpd_server = $CONF['smtp_server']; $smtpd_port = $CONF['smtp_port']; $smtp_server = $_SERVER["SERVER_NAME"]; $errno = "0"; $errstr = "0"; $timeout = "30"; $fh = @fsockopen($smtpd_server, $smtpd_port, $errno, $errstr, $timeout); if (!$fh) { return false; } else { fputs($fh, "EHLO {$smtp_server}\r\n"); $res = smtp_get_response($fh); fputs($fh, "MAIL FROM:<{$from}>\r\n"); $res = smtp_get_response($fh); fputs($fh, "RCPT TO:<{$to}>\r\n"); $res = smtp_get_response($fh); fputs($fh, "DATA\r\n"); $res = smtp_get_response($fh); fputs($fh, "{$data}\r\n.\r\n"); $res = smtp_get_response($fh); fputs($fh, "QUIT\r\n"); $res = smtp_get_response($fh); fclose($fh); } return true; }
/** * smtp_mail * Action: Send email * Call: smtp_mail (string to, string from, string subject, string body]) - or - * Call: smtp_mail (string to, string from, string data) - DEPRECATED * @param String - To: * @param String - From: * @param String - Subject: (if called with 4 parameters) or full mail body (if called with 3 parameters) * @param String (optional, but recommended) - mail body * @return bool - true on success, otherwise false * TODO: Replace this with something decent like PEAR::Mail or Zend_Mail. */ function smtp_mail($to, $from, $data, $body = "") { global $CONF; $smtpd_server = $CONF['smtp_server']; $smtpd_port = $CONF['smtp_port']; //$smtp_server = $_SERVER["SERVER_NAME"]; $smtp_server = php_uname("n"); $errno = "0"; $errstr = "0"; $timeout = "30"; if ($body != "") { $maildata = "To: " . $to . "\n" . "From: " . $from . "\n" . "Subject: " . encode_header($data) . "\n" . "MIME-Version: 1.0\n" . "Content-Type: text/plain; charset=utf-8\n" . "Content-Transfer-Encoding: 8bit\n" . "\n" . $body; } else { $maildata = $data; } $fh = @fsockopen($smtpd_server, $smtpd_port, $errno, $errstr, $timeout); if (!$fh) { error_log("fsockopen failed - errno: {$errno} - errstr: {$errstr}"); return false; } else { $res = smtp_get_response($fh); fputs($fh, "EHLO {$smtp_server}\r\n"); $res = smtp_get_response($fh); fputs($fh, "MAIL FROM:<{$from}>\r\n"); $res = smtp_get_response($fh); fputs($fh, "RCPT TO:<{$to}>\r\n"); $res = smtp_get_response($fh); fputs($fh, "DATA\r\n"); $res = smtp_get_response($fh); fputs($fh, "{$maildata}\r\n.\r\n"); $res = smtp_get_response($fh); fputs($fh, "QUIT\r\n"); $res = smtp_get_response($fh); fclose($fh); } return true; }