Jump to content

How i can send file attachment using sendemail API function


NelsonJPG

Recommended Posts

I need to send a pdf to a third party through a custom code, but i cant see how to to attach a file to the API, can you tell if there is a way to achieve what i need. I saw the WHMCS uses Phpmailer but i dont know how to require it and use it to send the mail. Thanks in advance.

 

this is how i send email normally...

 

   $command = "sendemail";
   $adminuser = "admin";
   $values["customtype"] = "general";
   $values["customsubject"] = "example email attachment";
   $values["custommessage"] = "example with file third party";
   $values["id"] = $userid;

   $results = localAPI($command, $values, $adminuser);

 

and this is what i would i like to do...

 

$email = new PHPMailer(); 
$email->From      = 'address1@example.com'; 
$email->FromName  = 'Name'; 
$email->Subject   = 'Message Subject'; 
$email->Body      = $bodytext; 
$email->AddAddress( 'destinationaddress@example.com' ); 

$file_to_attach = 'PATH_TO_FILE_HERE'; 

$email->AddAttachment( $file_to_attach , 'NameOfFile.pdf' ); 

$email->Send();

 

Thanks...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated