Jump to content
Grifen

PHPMailer + TCPDF attachement

Recommended Posts

Grifen

Boa noite pessoal, 

Tenho este codigo em php, se o ficheiro for um de texto ou uma imagem ele envia o mail certo com anexo se for um 

$pdf->Output($_SERVER["DOCUMENT_ROOT"].'/tmp/'.$doc_no.'.pdf', 'F');

ou 'S'

pdf em string o anexo ou mesmo salvo em disco e anexado não segue vai mail só com texto sem anexo.

 

Alguma ideia? isto já funcionou noutro ubuntu....

 


//email if request[mail] = 1
IF($_REQUEST[email] == '1'){

include '../../../../phpmailer/class.smtp.php';
include '../../../../phpmailer/class.phpmailer.php';

$def_mail=$database->query("SELECT * FROM fat_definicoes_email where ativo='1' and id_tipo_doc = '13'")->fetch();


$mail= new PHPMailer(); // defaults to using php "mail()"
$mail->IsSMTP();
$mail->Host = $def_mail[host];
$mail->SMTPAuth = true;
$mail->Username = $def_mail[username];
$mail->Password = $def_mail[password];
$mail->AddReplyTo($def_mail[email],$def_mail[nome_completo]);
$mail->SetFrom($def_mail[email], $def_mail[nome_completo]);
$mail->AddAddress($dados_cliente[email]);
$mail->Subject    = $def_mail[assunto];
//$mail->AltBody  = $def_mail[body]; // optional, comment out and test

$mail->Body = $def_mail[body].$anexo;// optional, comment out and test
$anexo = $_SERVER["DOCUMENT_ROOT"].'/tmp'.$doc_no.'.pdf';
$mail->addAttachment($anexo);      // attachment

if(!$mail->Send()) 
   {
    echo "Erro: " . $mail->ErrorInfo;
   } 
else 
  {
  echo "Enviado";
  unlink($anexo);
 }
 $window_close='window.close();';
$pdf->IncludeJS($window_close);
}

 

Share this post


Link to post
Share on other sites
13dev

Olá tenta rever estas duas linhas, o caminho destas duas classes pode estar errado:

Em 24/03/2017 às 23:09, Grifen disse:

include '../../../../phpmailer/class.smtp.php'; include '../../../../phpmailer/class.phpmailer.php';

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.