php - using phpmailer class to send attachment in email: Could not access file -


i have function below "sendmail", send emails using phpmailer class. , working fine, im sending emails sucess.

but im trying add 1 attachment function, added code:

$mail->addattachment(base.'/'.'images/2014/05/image4.jpg','image 4'); 

and im having error:

could not access file: localhost/project/images/2014/05/image4.jpg

but directory correct directory image, dont understand why error happening.

somebody there knows if im missing here?

my function send email:

 function sendmail($subject,$message,$emissor,$emissorname,$receptor,$receptorname, $reply = null, $replyname = null){      require_once('mail/class.phpmailer.php');       $mail = new phpmailer();      $mail->issmtp();      $mail->smtpauth = true;      $mail->ishtml(true);     $mail->smtpsecure = "tls";      $mail->host = mailhost;      $mail->port = mailport;      $mail->username = mailuser;     $mail->password = mailpass;         $mail->from = utf8_decode($emissor);      $mail->fromname = utf8_decode($emissorname);      $mail->subject = utf8_decode($subject);      $mail->body = utf8_decode($message);     $mail->addaddress(utf8_decode($receptor),utf8_decode($receptorname));      $mail->addattachment(base.'/'.'images/2014/05/image4.jpg','image 4');      if($reply != null){     $mail->addreplyto(utf8_decode($reply),utf8_decode($replynome));      }      if($mail->send()){     return true;     }     else{     return false;     } } 

and server acess file, when acess url: htttp://localhost/projeto/banner-imagens/2014/05/bib_idh.jpg, image!

your path incorrect. remove base , replace actual file path project folder. put in full path or relative path based on script.

add attachment path on filesystem. http://phpmailer.github.io/phpmailer/classes/phpmailer.html#method_addattachment

if doesn't fix make sure file readable. meaning file permissions set web server can access file.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -