phpbar.de logo

Mailinglisten-Archive

[php] Sendmail unter Windows - mail()

[php] Sendmail unter Windows - mail()

Frank Morer frankm69_(at)_hotmail.com
Mon, 24 Apr 2000 17:46:54 PDT


Hallo Jens,

es funktioniert, wenn Du den (eigentlich optionalen) letzten Parameter 
belegst! Z.B.:
mail(EMAILRECEIVER, $sSubject, $sMsg, "From: ".EMAILSENDER)

Alternativ, kannst Du auch die komplette Kommunikation mit dem Mailserver in 
PHP erschlagen:
function TransmitMyMail($nFilepointer, $sSubject, $sMsg)
{   //locals
    $sHeader = "";
    $sLine = "";

    $sHeader = "From: ".EMAILSENDER."\n";
    $sHeader = $sHeader."To: ".EMAILRECEIVER."\n";
    $sHeader = $sHeader."Reply-To: ".EMAILSENDER."\n";
    $sHeader = $sHeader."Subject: ".$sSubject."\r\n";
    if( !($sLine = fgets($nFilepointer, 1024)) )
    	return FALSE;
    if( !(fputs($nFilepointer, "HELO localhost\r\n")) )
    	return FALSE;
    if( !($sLine = fgets($nFilepointer, 1024)) )
    	return FALSE;
    if( !(fputs($nFilepointer, "MAIL FROM: ".EMAILSENDER."\r\n")) )
    	return FALSE;
    if( !($sLine = fgets($nFilepointer, 1024)) )
    	return FALSE;
    if( !(fputs($nFilepointer, "RCPT TO: ".EMAILRECEIVER."\r\n")) )
    	return FALSE;
    if( !($sLine = fgets($nFilepointer, 1024)) )
    	return FALSE;
    if( !(fputs($nFilepointer, "DATA\r\n")) )
    	return FALSE;
    if( !($sLine = fgets($nFilepointer, 1024)) )
    	return FALSE;
    if( !(fputs($nFilepointer, $sHeader."\r\n\r\n")) )
    	return FALSE;
    if( !(fputs($nFilepointer, $sMsg."\r\n")) )
    	return FALSE;
    if( !(fputs($nFilepointer, ".\r\n")) )
    	return FALSE;
    if( !($sLine = fgets($nFilepointer, 1024)) )
    	return FALSE;
    if( !(fputs($nFilepointer, "QUIT\r\n")) )
    	return FALSE;
    if( !($sLine = fgets($nFilepointer, 1024)) )
    	return FALSE;
    return TRUE;
};
function SendMyMail($sSubject, $sMsg)
{   //locals
    $nFilepointer = 0;
    $bSendStatus = FALSE;

    if( !($nFilepointer = fsockopen(EMAILSERVER, 25)) )
    	return FALSE;
    $bSendStatus = TransmitMyMail($nFilepointer, $sSubject, $sMsg);
    fclose($nFilepointer);
    return $bSendStatus;
};

Funktionsaufruf: SendMyMail($sSubject, $sMsg)

Sollte jetzt gehen...

Gruß vom Frank

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com



php::bar PHP Wiki   -   Listenarchive