Re: Need help with PHP -> Mail -> SMTP -> Windows Exchange

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 31 Jul 2004 10:37:53 -0400, Andrew English
<andrew@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> I am trying to get my web page ready for uploading when I ran into a snag.
> The person who supplied me with the php code for the contact page gave me
> the send mail code. I am wondering if anyone can help me out with converting
> the code so I can sent it via SMTP Auth?
> 
> Here is what I got from the person.
> 
> <?PHP
> $to = "contact@xxxxxxxxxxxxxxxxx";
> $msg .= "This message has been sent from your Contact Form\n\n";
> $msg .= "Name: $name\n";
> $msg .= "Email: $email\n";
> $msg .= "Website: $website\n";
> $msg .= "Address 1: $address1\n";
> $msg .= "Address 2: $address2\n";
> $msg .= "City: $city\n";
> $msg .= "State: $state\n";
> $msg .= "Zip Code: $zip\n";
> $msg .= "Country: $country\n";
> $msg .= "Message: $comment\n";
> mail($to, $name, $msg, "From: Contact Form\nReply-To: $email\n");
> ?>
> 
> And here what I found on the net for doing SMTP Auth.
> 
> <? php
> 
> //mail($catre, $subject, $message, $headers); //old fashion mail, using
> sendmail, useful on linux
> sock_mail($catre, $subject, $message, $headers,$from);//sock version, usable
> on Win32
> 
> //this is the sock mail function
> function sock_mail($auth,$to, $subj, $body, $head, $from){
>        $lb="\r\n";                        //linebreak
>        $body_lb="\r\n";                //body linebreak
>        $loc_host = "localhost";        //localhost
>        $smtp_acc = "steve";        //account
>        $smtp_pass="jonson";            //password
>        $smtp_host="smtp.server.com";    //server SMTP
>        $hdr = explode($lb,$head);        //header
> 
>        if($body) {$bdy =
> preg_replace("/^\./","..",explode($body_lb,$body));}
> 
>        // build the array for the SMTP dialog. Line content is
> array(command, success code, additonal error message)
>        if($auth == 1){// SMTP authentication methode AUTH LOGIN, use
> extended HELO "EHLO"
>            $smtp = array(
>                // call the server and tell the name of your local host
>                array("EHLO ".$loc_host.$lb,"220,250","HELO error: "),
>                // request to auth
>                array("AUTH LOGIN".$lb,"334","AUTH error:"),
>                // username
>                array(base64_encode($smtp_acc).$lb,"334","AUTHENTIFICATION
> error : "),
>                // password
>                array(base64_encode($smtp_pass).$lb,"235","AUTHENTIFICATION
> error : "));
>        }
>        else {// no authentication, use standard HELO
>            $smtp = array(
>                // call the server and tell the name of your local host
>                array("HELO ".$loc_host.$lb,"220,250","HELO error: "));
>        }
> 
>        // envelop
>        $smtp[] = array("MAIL FROM: <".$from.">".$lb,"250","MAIL FROM error:
> ");
>        $smtp[] = array("RCPT TO: <".$to.">".$lb,"250","RCPT TO error: ");
>        // begin data
>        $smtp[] = array("DATA".$lb,"354","DATA error: ");
>        // header
>        $smtp[] = array("Subject: ".$subj.$lb,"","");
>        $smtp[] = array("To:".$to.$lb,"","");
>        foreach($hdr as $h) {$smtp[] = array($h.$lb,"","");}
>        // end header, begin the body
>        $smtp[] = array($lb,"","");
>        if($bdy) {foreach($bdy as $b) {$smtp[] = array($b.$body_lb,"","");}}
>        // end of message
>        $smtp[] = array(".".$lb,"250","DATA(end)error: ");
>        $smtp[] = array("QUIT".$lb,"221","QUIT error: ");
> 
>        // open socket
>        $fp = @fsockopen($smtp_host, 25);
>        if (!$fp) echo "<b>Error:</b> Cannot conect to ".$smtp_host."<br>";
> 
>        $banner = @fgets($fp, 1024);
>        // perform the SMTP dialog with all lines of the list
>        foreach($smtp as $req){
>            $r = $req[0];
>            // send request
>            @fputs($fp, $req[0]);
>            // get available server messages and stop on errors
>            if($req[1]){
>                while($result = @fgets($fp, 1024)){if(substr($result,3,1) ==
> " ") { break; }};
>                if (!strstr($req[1],substr($result,0,3)))
> echo"$req[2].$result<br>";
>            }
>        }
>        $result = @fgets($fp, 1024);
>        // close socket
>        @fclose($fp);
>        return 1;
>    }
> 
> ?>
> 
> Your help would be appreciate it! Thanks
> 

So what's your problem exactly?

You could always try going with another mailing solution:
http://pear.php.net/package/Mail

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux