0

I use Phpmailer to send emails, but have a problem with sending an attachment. I tried this:

$mail->AddAttachment($_SERVER[DOCUMENT_ROOT].'/test.pdf','doklad.pdf');

and this:

$mail->AddAttachment($_SERVER[DOCUMENT_ROOT].'/test.pdf','doklad.pdf','base64','application/pdf');

and this:

$mail->AddStringAttachment(file_get_contents($_SERVER[DOCUMENT_ROOT].'/test.pdf'),'doklad.pdf','base64','application/pdf');

Phpmailer always sends an attachment but no physical file.

Can you help me to solve it?

  • Possible duplicate of [Send File Attachment from Form Using phpMailer and PHP](https://stackoverflow.com/questions/11764156/send-file-attachment-from-form-using-phpmailer-and-php) – bigwolk Apr 13 '18 at 10:05
  • Additionally please check with `file_exists` if `$_SERVER[DOCUMENT_ROOT].'/test.pdf'` exists and has correct path. – bigwolk Apr 13 '18 at 10:07
  • What do you mean by "Phpmailer always sends an attachment but no physical file."? That makes no sense! Also, check the return value of all of these. – Synchro Apr 13 '18 at 10:38
  • File exists, its content is sent in source, email has 1.2 MB, but no physical attachment. – Mír Oslav Apr 13 '18 at 12:59
  • Problem is that I use also AddEmbeddedImage. If image is not embeded, attachment is sent as physical file. So...? :-O – Mír Oslav Apr 13 '18 at 13:20
  • SOLVED: New version of Phpmailer (6.0.5) solved it. – Mír Oslav Apr 13 '18 at 14:01

0 Answers0