note 32650 added to function.mail

From: Date: Tue, 03 Jun 2003 19:52:24 +0000
Subject: note 32650 added to function.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-49655@lists.php.net to get a copy of this message
If you can't use the mail() function to send an email or if you wish to build up the complete mail from scratch, you can use fsockopen. Here's how: $smtp = fsockopen("localhost", "25"); // Open a connection to the SMTP server (25 = standard smtp port) fwrite($smtp, "HELO localhost\r\n"); // Identify yourself to the server fwrite($smtp, "MAIL FROM: <my.email@job.com>\r\n"); // Sender fwrite($smtp, "RCPT TO: <to.whom@other.com>\r\n"); // Reciever fwrite($smtp, "DATA\r\n"); // Start pushing mail headers & email to the server from the next line fwrite($smtp, "From: \"My Name\" <my.email@job.com>>\r\n"; fwrite($smtp, "Reply-To: <my.email@job.com>\r\n"; fwrite($smtp, "To: to.whom@other.com\r\n"; fwrite($smtp, "Subject: My First Email\r\n"; fwrite($smtp, "Date: ".date("r")."\r\n"; fwrite($smtp, "MIME-Version: 1.0\r\n"; fwrite($smtp, "Content-type: text/plain;\r\n"; fwrite($smtp, "\r\n"; // Blank line before the body fwrite($smtp, "Body of email\r\n"; fwrite($smtp, "\r\n"; fwrite($smtp, ".\r\n"); // Send a dot to tell the server you wanna stop pushing the headers. fwrite($smtp, "QUIT\r\n"); // Stop building up mail & send it fclose($smtp); // Close connection. Those might not be the best way but it sure works. I had some problems sending lots of headers (multipart mail) using mail() / imap_mail(). Works great this way. ---- Manual Page -- http://www.php.net/manual/en/function.mail.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32650 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32650&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32650&report=yes

« previous php.notes (#49655) next »