compilado = false; $this->destinatarios = $destinatarios; $this->assunto = $assunto; $this->conteudo = $conteudo; $this->footer = $strFooter; $this->template = ( $template )? $template : "email_padrao"; $this->remetente = ( $remetente )? $remetente: "sistema@itajai.sc.gov.br"; $this->remetenteNome = ( $remetenteNome ) ? $remetenteNome: "Sistema - Itajai.sc.gov.br"; $this->replyto = ( $replyto )? $replyto: $remetente; $this->tipo = ( $tipo == "html" )? "text/html": "text/plain"; } function compilar() { if( $this->tipo != "text/html" ) { $this->conteudoCompilado = $this->conteudo; } else { $arquivo = "templates/{$this->template}.tpl"; $ptrTpl = fopen( $arquivo, "r"); $strArquivo = fread($ptrTpl, filesize($arquivo)); fclose ($ptrTpl); $strArquivo = str_replace( "", $this->conteudo, $strArquivo ); $strArquivo = str_replace( "", $this->assunto, $strArquivo ); if( $this->footer ) { $strArquivo = str_replace( "", $this->footer, $strArquivo ); } $this->conteudoCompilado = $strArquivo; } $this->compilado = true; } function envia() { if( ! $this->compilado ) $this->compilar(); $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: {$this->tipo}; charset={$this->charset}\n"; $headers .= "X-Priority: 3\n"; $headers .= "X-MSMail-Priority: Normal\n"; $headers .= "X-Mailer: php/" . phpversion() . "\n"; $headers .= "From: \"{$this->remetenteNome}\" <{$this->remetente}>\n"; $headers .= "Reply-To: {$this->replyto}\n"; if( is_array( $this->destinatarios ) ) { $this->destinatarios = implode( ",", $this->destinatarios ); } $this->destinatarios = str_replace( " ", ",", $this->destinatarios ); $ok = mail( $this->destinatarios, $this->assunto, $this->conteudoCompilado, $headers ); return $ok; } function addDestinatario( $email ) { if( is_array( $this->destinatarios ) ) { $this->destinatarios[] = $email; } else { if( $this->destinatarios != "" ) { $this->destinatarios .= ",{$email}"; } else { $this->destinatarios = $email; } } } } ?>