Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'Mail.php';
- include 'Mail/mime.php';
- $host = 'smtp.gmail.com';
- $from = 'penteado.vanessa@gmail.com';
- $username = 'penteado.vanessa@gmail.com';
- $password = 'umdoistres';
- $to = 'ricardo.jportela@gmail.com';
- $body = 'teste';
- $html = '<html><body>HTML version of email</body></html>';
- $file = 'correio.php';
- //$body = utf8_decode($body);
- $subject = utf8_decode('c\'est lavie en rose');
- $crlf = "\n";
- $recipients = $to;
- $mime = new Mail_mime(array('eol' => $crlf));
- $mime->setTXTBody($body);
- $mime->setHTMLBody($html);
- $mime->addAttachment($file, 'text/plain');
- $body = $mime->get();
- $headers = array('From' => $from, 'To' => $to, 'Subject' => $subject);
- $hdrs = $mime->headers($headers);
- $smtp = Mail::factory('smtp', array('host' => $host,
- 'port' => 587, // SMTP
- 'auth' => true, 'debug' => true,
- 'username' => $username,
- 'password' => $password)
- );
- $mail = $smtp->send($recipients, $hdrs, $body);
- if (PEAR::isError($mail)) {
- echo $mail->getMessage();
- } else {
- echo "Enviado com sucesso";
- }
- ?>
Add Comment
Please, Sign In to add comment