note 71218 deleted from function.mail by tularis

From: Date: Thu, 16 Nov 2006 23:11:29 +0000
Subject: note 71218 deleted from function.mail by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-119821@lists.php.net to get a copy of this message
Note Submitter: Niklas Andersson Reason: useless ---- Here you have a function that can send a mail through the server you specify in gethostbyname: I.e - no need to have local MTA or mail installed function sendmail($from,$to,$subject,$message,$headers) { $address = gethostbyname("www.cport.se"); $service_port = getservbyname("smtp","tcp"); $headers .= "Subject: $subject\r\n"; $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if ($socket < 0) { echo "socket_create() failed: reason: " . socket_strerror($socket) . "\n"; } $result = socket_connect($socket, $address, $service_port); $in = "HELO localhost\r\n"; $in .= "MAIL FROM:<$mail>\r\n"; $in .= "RCPT TO:<$to>\r\n"; $in .= "DATA\r\n"; $in .= $headers; $in .= $message; $in .= "\r\n.\r\n"; socket_write($socket, $in, strlen($in)); socket_close($socket); }

« previous php.notes (#119821) next »