note 85022 added to function.mail

From: Date: Mon, 11 Aug 2008 13:48:11 +0000
Subject: note 85022 added to function.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-143358@lists.php.net to get a copy of this message
Enviar e-mail com autenticação: *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"); ?> testado com gmail / sites hospedados na auriance.net *It was tried with Gmail / auriance.net, bol, terra, yahoo by Raphael (BRASIL) ---- Server IP: 200.185.126.110 Probable Submitter: 201.35.58.178 ---- Manual Page -- http://www.php.net/manual/en/function.mail.php Edit -- https://master.php.net/note/edit/85022 Del: integrated -- https://master.php.net/note/delete/85022/integrated Del: useless -- https://master.php.net/note/delete/85022/useless Del: bad code -- https://master.php.net/note/delete/85022/bad+code Del: spam -- https://master.php.net/note/delete/85022/spam Del: non-english -- https://master.php.net/note/delete/85022/non-english Del: in docs -- https://master.php.net/note/delete/85022/in+docs Del: other reasons-- https://master.php.net/note/delete/85022 Reject -- https://master.php.net/note/reject/85022 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#143358) next »