Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Mailer {
- //aqui é uma constatne para configurar usuario/ senha e nome que vai aparecer no titulo dp email
- const USERNAME = "";
- const PASSWORD = "";
- const NAME_FROM = "Hcode Store";
- private $mail;
- // No contrutor recebemos 3 paramentros que toAddess = email para vou mardar, toName = nome do cara, subject = assunto
- public function __construct($toAddress,$toName,$subjec)
- {
- utf8_encode($toAddress);
- utf8_encode($toName);
- utf8_encode($subject);
- echo "<h1>".(extension_loaded('openssl')?'SSL loaded':'SSL not loaded')."</h1>"."\n";
- $this->mail = new \PHPMailer();
- $this->mail->WordWrap = 50;
- $this->mail->isHTML(true);
- $this->mail->SMTPSecure = 'ssl';
- $this->mail->isSMTP();
- $this->mail->SMTPDebug = 0;
- $this->mail->Host = 'smtp.gmail.com';
- $this->mail->Port = 465;
- $this->mail->SMTPAuth = true;
- $this->mail->SMTPOptions = array(
- 'ssl' => array(
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => false
- )
- );
- $this->mail->Username = Mailer::USERNAME;
- $this->mail->Password = Mailer::PASSWORD;
- $this->mail->setFrom(Mailer::USERNAME,Mailer::NAME_FROM);
- $this->mail->addAddress($toAddress,$toName);
- $this->mail->Subject = ($subject);
- $this->mail->msgHTML($html);
- $this->mail->AltBody ="Alternativo";
- }
- public function send()
- {
- return $this->mail->send();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement