Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $mpdf = new MpdfMpdf();
- $mpdf->WriteHTML('Stack Overflow');
- $mpdf->Output('php://temp', MpdfOutputDestination::FILE);
- $mail = new PHPMailer(true);
- try {
- //Server settings
- $mail->SMTPDebug = 0;
- $mail->isSMTP();
- $mail->Host = 'smtp1.example.com;smtp2.example.com'; //Configure o seu SMTP
- $mail->SMTPAuth = true;
- $mail->Username = 'user@example.com'; // usuario
- $mail->Password = 'secret'; // senha
- $mail->SMTPSecure = 'tls'; // TLS se tiver criptografia
- $mail->Port = 587; //Porta do SMTP
- //Destinatários
- $mail->setFrom('guilherme@pt.stackoverflow.com');
- //ADICIONA O ANEXO AQUI
- $mail->addAttachment('php://temp', 'Arquivo.pdf');
- $mail->isHTML(true);
- $mail->Subject = 'ASSUNTO';
- $mail->Body = 'Mensagem';
- $mail->AltBody = 'mensagem para clientes de email que não usam HTML';
- $mail->send();
- echo 'Mensagem enviada';
- } catch (Exception $e) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- }
Add Comment
Please, Sign In to add comment