Skip to content
Advertisement

Use PHPmailer to send attachment

I’m using PHPmailer library to send emails and I need to send an attachment.

Currently the file is stored on the server and I have the link to the file stored in var $link.

I’m using the following to try and add the attachment but the email arrives with no attachment:

JavaScript

I have also tried it with a hardcoded path instead of my variable:

JavaScript

The email shows up but does not have any attachment.

I have tried using phpmailerException to grab any errors but get no response.

How else can I send an attachment with PHPmailer?

Full PHP code:

JavaScript

Advertisement

Answer

The Problem is that the function AddAttachment uses the function is_file() and is file returns false when accessing URLs (this also applies to relative URLs), is_file() only accepts filepaths. So normally phpmailer should add an error to the error container.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement