Commit bc180b66e9602230a7e8f429d26e8f0c5cbe186c
1 parent
a96f0400
Exists in
master
Inserção do PHP MAILER na estrutura de security.php
Showing
1 changed file
with
43 additions
and
1 deletions
Show diff stats
restrito/inc/security.php
... | ... | @@ -47,6 +47,48 @@ function sendMail($to, $subject,$body,$from="",$fromname="") |
47 | 47 | |
48 | 48 | } |
49 | 49 | |
50 | +//Funcao email para Linux - PHP MAILER | |
51 | + | |
52 | + | |
53 | +function sendMail($to, $subject, $body, $from="", $fromname=""){ | |
54 | + require_once("../class/PHPMailerAutoload.php"); | |
55 | + $mail = new PHPMailer(); | |
56 | + $mail->isSMTP(); // Define que a mensagem será SMTP | |
57 | + $mail->Host = "0.0.0.0"; //hostname ou IP do Servidor | |
58 | + //$mail->SMTPAuth = true; //Caso seu email precise de autenticação, no nosso caso não. | |
59 | + //$mail->Username = "seuemail@dominio.com"; | |
60 | + //$mail->Passowrd = "sua senha"; | |
61 | + if(empty($from)){ | |
62 | + $sql = "SELECT nomeremetenteemail, emailremetente FROM lda_configuracao"; | |
63 | + $rs = execQuery($sql); | |
64 | + $row = mysql_fetch_array($rs); | |
65 | + $mail->From = $row['emailremetente']; | |
66 | + $mail->FromName = $row['nomeremetenteemail']; | |
67 | + }else{ | |
68 | + $mail->From = $from; | |
69 | + $mail->FromName = $fromname; | |
70 | + } | |
71 | + $mail->addAddress($to); | |
72 | + $mail->isHTML(true); //Define que o email será HTML | |
73 | + $mail->CharSet = "iso-8859-1"; //Charset da mensagem (opcional) | |
74 | + $mail->Subject = $subject; | |
75 | + $html = "<html> | |
76 | + <body> | |
77 | + $body | |
78 | + </body> | |
79 | + </html>"; | |
80 | + $mail->Body = $html; | |
81 | + $mail->AltBody = $body; //Texto Plano (opcional) | |
82 | + $envia = $mail->send(); //Envia o email | |
83 | + $mail->clearAllRecipients(); //Limpa os destinatarios | |
84 | + if($envia){ //Retorno do email | |
85 | + return TRUE; | |
86 | + }else{ | |
87 | + return FALSE; | |
88 | + } | |
89 | +} | |
90 | + | |
91 | + | |
50 | 92 | |
51 | 93 | function sendMailAnexo($to, $subject,$body,$arquivos=array(),$from="",$fromname="",$cc="") |
52 | 94 | { |
... | ... | @@ -367,4 +409,4 @@ function isauth($tipo="consumidor") { |
367 | 409 | |
368 | 410 | session_start(); |
369 | 411 | |
370 | -?> | |
371 | 412 | \ No newline at end of file |
413 | +?> | ... | ... |