Created
December 6, 2011 13:28
-
-
Save danjesus/1438205 to your computer and use it in GitHub Desktop.
Diesel Email Helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Classe reponsável pelo envio de e-mails na aplicação | |
| * | |
| */ | |
| class EmailHelper { | |
| /** | |
| * Recebe as configurações de envio | |
| * @var $config = array | |
| */ | |
| public $config = array( | |
| "USER"=> "",//User E-mail | |
| "PASS"=> "",//User Pass | |
| "PORT"=> "",//PORT | |
| "HOST"=> ""//SMTP SERVER | |
| ); | |
| public $subject = "Envio de email"; | |
| public $toEmail = "pedidosite@helpmicros.com.br"; | |
| public $toName = "Help Micros"; | |
| public $fromEmail; | |
| public $fromName; | |
| public $body; | |
| public $htmlMessage; | |
| public function sendMail() { | |
| date_default_timezone_set('America/Sao_Paulo'); | |
| $mail = new PHPMailer(); | |
| $mail->SetLanguage('en'); | |
| $mail->IsSMTP(); | |
| $mail->SMTPDebug = 1; | |
| //Configurações de Envio | |
| $mail->SMTPAuth = true; | |
| //$mail->SMTPSecure = $this->config["SSL"]; | |
| $mail->Host = $this->config["HOST"]; | |
| $mail->Port = $this->config["PORT"]; | |
| $mail->Username = $this->config["USER"]; | |
| $mail->Password = $this->config["PASS"]; | |
| //Adiciona Cópia para o Destinatário da Mensagem | |
| $mail->AddCC($this->fromEmail, $this->fromName); | |
| //Envio | |
| $mail->SetFrom($this->toEmail, 'Help Micros'); | |
| $mail->AddReplyTo($this->fromEmail, $this->fromEmail); | |
| $mail->Subject = $this->subject; | |
| $mail->AltBody = "Para visualizar a mensagem, por favor, use um cliente de e-mail | |
| compatível/configurado para ver mensagens HTML!"; | |
| $mail->MsgHTML(utf8_decode($this->htmlMessage)); | |
| $mail->AddAddress($this->toEmail, $this->toName); | |
| if (!$mail->Send()) { | |
| echo "Erro: " . $mail->ErrorInfo; | |
| exit; | |
| } else { | |
| return true; | |
| } | |
| $mail->ClearAllRecipients(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment