Last active
December 16, 2015 06:59
-
-
Save georgemendonca/5395124 to your computer and use it in GitHub Desktop.
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 | |
| /** | |
| * @author George Mendonça | |
| * www.georgemendonca.com.br | |
| * 16/04/2013 | |
| */ | |
| // Chamando a classe PHPMailer | |
| require_once 'class.phpmailer.php'; | |
| // Instanciando o objeto da classe PHPMailer | |
| $email = new PHPMailer(); | |
| // Envio de e-mail via servidor SMTP | |
| $email->isSMTP(); | |
| // Configuração do servidor SMTP | |
| $email->Host = "ssl://smtp.googlemail.com"; | |
| $email->SMTPAuth = true; | |
| $email->SMTPDebug = true; | |
| $email->Port = 465; | |
| $email->Username = "seu-email@gmail.com"; | |
| $email->Password = "sua-senha"; | |
| // Remetente da mensagem | |
| $email->From = "seu-email@gmail.com"; | |
| $email->FromName = "Seu Nome"; | |
| // Destinatários do e-mail | |
| $email->AddAddress("garrincha@dominio.com.br", | |
| "Garrincha, o Mestre do Drible"); | |
| $email->AddAddress("pele@dominio.com", "Pelé o Rei do Futebol"); | |
| $email->AddAttachment('imagem.gif'); | |
| $email->AddAttachment('seudoc.odt'); | |
| // Envio de e-mail no formato HTML | |
| $email->IsHTML(true); | |
| // Assunto e corpo da mensagem e-mail | |
| $email->Subject = "Enviando e-mail com a classe PHPMailer no PHP"; | |
| $email->Body = "Este é um exemplo simples de envio | |
| de e-mail com Gmail utilizando a classe PHPMailer."; | |
| // Enviando o e-mail | |
| if ( $email->Send() ) { | |
| echo "E-mail enviado com sucesso!"; | |
| } | |
| else { | |
| echo "Erro ao enviar o e-mail!"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment