This is what I use and makes life much much easier
Pete
Maria Garcia Suarez wrote:
Hi there!
I'm developing a program that has a kind of mail client from where users can send mails and get a blind copy in their e-mail boxes. The program uses mail() in those servers having a SMTP installed in the very same server. I would like to let people send mails even if the server is not able to handle them.
To do that I've googled around and found the following script (see below). The problem is that blind copies don't reach destination, mails in the To: field arrive well, mails in the BCC: desappear and never reach the mailbox (nor get back :-?
Does anyone know what's going wrong? Thanks.
<? /* pipemail v.0.1
PHP-script to send mails via socket, e.g. using an external smtp-server
(c) Robert Strouhal 2002 http://www.strouhal.de
Feel free to use, copy and modify this script. PLEASE REMIND: IT COMES WITH ABSOLUTELY NO GUARANTEE!
How to use: ------- Integrate the file to your own sripts by using "require" or "inlude" Modify the setting in line 30-32 gosmtp($from,$to,$subject,$cc,$bcc,$message); Example: gostmtp("[EMAIL PROTECTED]", "[EMAIL PROTECTED]", "This is my subject", "","", "This is my message to you"); */
// settings, please modify for your own website global $server, $port, $logsmtp; $server = "$mailServer"; //domain of your smtp-server $port = 25; //SMTP-Port, usually 25 $logsmtp = 1; //set 1 if the smtp communication should be logged to the file smtp.log in the same folder
// don't edit the code below as long as you don't know what to do...
function listen2server() {
global $log; global $server; global $socket; global $logsmtp;
$antwort = fgets($socket, 1500);
if ($logsmtp=='1') { $log = "SERVER: ".$antwort; $datei = fopen("smtp.log", "a"); fputs($datei, "$log"); fclose($datei); }
$code = substr($antwort, 0, 3); return $code;
}
function talk2server($commands) {
global $log;
global $server;
global $socket;
global $logsmtp;
fputs($socket,$commands);
if ($logsmtp=='1') { $log = "CLIENT: ".$commands; $datei = fopen("smtp.log", "a"); fputs($datei, "$log"); fclose($datei); } }
function gosmtp($from,$to,$subject,$cc,$bcc,$message) {
global $server; global $socket; global $port; global $logsmtp; if ($socket = fsockopen($server,$port)) { //set_socket_timeout($socket, 30); if (listen2server() == "220") talk2server("HELO ".getenv('HTTP_HOST')."\n"); if (listen2server() == "250") talk2server("MAIL FROM: ".$from."\n"); if (listen2server() == "250") talk2server("RCPT TO: ".$to."\n"); if (listen2server() == "250") talk2server("DATA\n"); if (listen2server() == "354") { $content = "Subject: $subject\r\n"; $content .= "From: $from\r\n"; $content .= "To: $to\r\n"; if ($cc!="") { $content .= "Cc: $cc\r\n"; } if ($bcc!="") { $content .= "Bcc: $bcc\r\n"; } $content .= "Reply-To: $from\r\n"; $content .= "Errors-To: $from\r\n"; $content .= "Bounce-To: $from\r\n"; $content .= "X-Mailer: sent via PipeMail v0.1, check www.strouhal.de for the PHP script\r\n"; $content .= "X-Please_remind: I am not responsible for the misuse (spam...) of this script!\r\n"; $content .= "\r\n".$message."\r\n"; $content .= ".\r\n"; echo "<PRE>$content</PRE>"; talk2server($content); if (listen2server() == "250") {//listen2server(); $mailsent = true;} else {$mailsent = false; //listen2server(); }
}
talk2server("QUIT\n");
listen2server();
if ($mailsent) {
echo "<P>Mail sent</P>";
return true;
} else {
echo "<tt><font color='red'>Couldn't deliver
mail to $to!</b></font></tt><br>\n";
return false;
}
}
else { echo "<tt><font color='red'>Wasn't able to connect to $server:$port!</b></font></tt><br>"; return false; } }
?>
__________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php