braveo:classemail
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédente | |||
braveo:classemail [2015/03/29 18:48] – arnaudr | braveo:classemail [2024/04/16 22:20] (Version actuelle) – modification externe 127.0.0.1 | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ==== MAIL.class.php ==== | ||
+ | |||
+ | <code PHP> | ||
+ | <?php | ||
+ | |||
+ | / | ||
+ | /* */ | ||
+ | /* | ||
+ | /* |\/| |__| | [__ | | |\ | | \ | | | | |__] |__/ |___ */ | ||
+ | /* | ||
+ | /* */ | ||
+ | / | ||
+ | /* */ | ||
+ | /* Titre : MAIL.class.php | ||
+ | /* */ | ||
+ | /* URL : http:// | ||
+ | /* Auteur : : Ivan Priorov | ||
+ | /* Modification | ||
+ | /* Date édition | ||
+ | /* */ | ||
+ | /* */ | ||
+ | / | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | class Mail { | ||
+ | |||
+ | private $smtpServer = ' | ||
+ | |||
+ | private $port = ' | ||
+ | |||
+ | private $timeout = ' | ||
+ | |||
+ | // private $from = ' | ||
+ | |||
+ | private $newline = " | ||
+ | |||
+ | private $localdomain = ' | ||
+ | |||
+ | private $charset = ' | ||
+ | |||
+ | private $contentTransferEncoding = false; | ||
+ | |||
+ | |||
+ | |||
+ | // Do not change anything below | ||
+ | |||
+ | private $smtpConnect = false; | ||
+ | |||
+ | | ||
+ | |||
+ | private $from = false; | ||
+ | |||
+ | private $to = false; | ||
+ | |||
+ | private $subject = false; | ||
+ | |||
+ | private $message = false; | ||
+ | |||
+ | private $headers = false; | ||
+ | |||
+ | private $logArray = array(); // Array response message for debug | ||
+ | |||
+ | private $Error = ''; | ||
+ | |||
+ | |||
+ | |||
+ | public function __construct($from, | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | // Connect to server | ||
+ | |||
+ | if(!$this-> | ||
+ | |||
+ | // Display error message | ||
+ | |||
+ | echo $this-> | ||
+ | |||
+ | print_r($this-> | ||
+ | |||
+ | echo $this-> | ||
+ | |||
+ | return false; | ||
+ | |||
+ | } | ||
+ | |||
+ | return true; | ||
+ | |||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | private function Connect2Server() { | ||
+ | |||
+ | // Connect to server | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | |||
+ | |||
+ | if (!is_resource($this-> | ||
+ | |||
+ | return false; | ||
+ | |||
+ | } | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | // Hi, server! | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | | ||
+ | |||
+ | // " | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | if (substr($this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | return false; | ||
+ | |||
+ | } | ||
+ | |||
+ | // " | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | if (substr($this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | } | ||
+ | |||
+ | // Send data to server | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | // Send mail message | ||
+ | |||
+ | if (!$this-> | ||
+ | |||
+ | // Good bye server! =) | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | // Close smtp connect | ||
+ | |||
+ | fclose($this-> | ||
+ | |||
+ | return true; | ||
+ | |||
+ | } | ||
+ | |||
+ | // Function send mail | ||
+ | |||
+ | private function sendMail() { | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | if(substr($this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | return false; | ||
+ | |||
+ | } | ||
+ | |||
+ | return true; | ||
+ | |||
+ | } | ||
+ | |||
+ | // Function read response | ||
+ | |||
+ | private function readResponse() { | ||
+ | |||
+ | $data=""; | ||
+ | |||
+ | while($str = fgets($this-> | ||
+ | |||
+ | { | ||
+ | |||
+ | $data .= $str; | ||
+ | |||
+ | if(substr($str, | ||
+ | |||
+ | } | ||
+ | |||
+ | return $data; | ||
+ | |||
+ | } | ||
+ | |||
+ | // function send command to server | ||
+ | |||
+ | private function sendCommand($string) { | ||
+ | |||
+ | fputs($this-> | ||
+ | |||
+ | return ; | ||
+ | |||
+ | } | ||
+ | |||
+ | // function send headers | ||
+ | |||
+ | private function sendHeaders() { | ||
+ | |||
+ | // | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | if ($this-> | ||
+ | |||
+ | $this-> | ||
+ | |||
+ | return ; | ||
+ | |||
+ | } | ||
+ | |||
+ | |||
+ | public function __destruct() { | ||
+ | |||
+ | if (is_resource($this-> | ||
+ | |||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | ?> | ||
+ | </ | ||