note 85022 deleted from function.mail by nicos

From: Date: Mon, 11 Aug 2008 18:35:11 +0000
Subject: note 85022 deleted from function.mail by nicos
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-143373@lists.php.net to get a copy of this message
Note Submitter: raphaelgringo at gmail dot com Reason: non-english ---- Send mail with authentication: <?php class Smtp{ var $conn; var $user = "seusite@seusite.com.br"; //you@yoursite.com var $pass = "suasenha"; //your password var $debug = true; //for use authentication var $host = "mail.seuservidor.com.br"; //your smtp server var $porta = 25; //port function Smtp(){ $this->conn = fsockopen($this->host, $this->porta, $errno, $errstr, 30); $this->Put("EHLO $host"); } function Auth(){ $this->Put("AUTH LOGIN"); $this->Put(base64_encode($this->user)); $this->Put(base64_encode($this->pass)); } function Send($to, $from, $subject, $msg){ $this->Auth(); $this->Put("MAIL FROM: " . $from); $this->Put("RCPT TO: " . $to); $this->Put("DATA"); $this->Put($this->toHeader($to, $from, $subject)); $this->Put("\r\n"); $this->Put($msg); $this->Put("."); $this->Close(); if(isset($this->conn)) return true; else return false; } function Put($value){ return fputs($this->conn, $value . "\r\n"); } function toHeader($to, $from, $subject){ $header = "Message-Id: <". date('YmdHis').".". md5(microtime()).".". strtoupper($from) ."> \r\n"; $header .= "From: <" . $from . "> \r\n"; $header .= "To: <".$to."> \r\n"; $header .= "Subject: ".$subject." \r\n"; $header .= "Date: ". date('D, d M Y H:i:s O') ." \r\n"; $header .= "X-MSMail-Priority: High \r\n"; $header .= "Content-Type: Text/HTML"; return $header; } function Close(){ $this->Put("QUIT"); if($this->debug == true){ while (!feof ($this->conn)) { fgets($this->conn) . "<br>\n"; } } return fclose($this->conn); } } $smtp = new Smtp(); $smtp->Send("exemplo@site.com.br","seuemail@seusite.com.br", "Assunto", "Mensagem"); ?> It was tried with Gmail / auriance.net, bol, terra, yahoo by Raphael (BRASIL)

« previous php.notes (#143373) next »