wonderdev Posted March 16, 2019 Share Posted March 16, 2019 We have client contracts that is generated in our external system, is there a API function etc. to easy attach files to clients or do we have to do this manually per clients? ! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 17, 2019 Share Posted March 17, 2019 22 hours ago, wonderdev said: We have client contracts that is generated in our external system, is there a API function etc. to easy attach files to clients or do we have to do this manually per clients? ! i'm not aware of any API for client downloads (technically uploads I suppose) - there are some for attaching files to tickets, but not this.... also, i'm not aware of any third-party addon that can do this either. I suppose it is possible to write a solution that uploads the file to the downloads directory and updates the appropriate database table with filename/client details - but not via the default API. 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted March 20, 2019 Share Posted March 20, 2019 Workaround 1: Instead of sending an email, attach your file via API in a ticket with OpenTicket or AddTicketReply. Workaround 2: Alternatively provide a download link in your email. They can download the contract on click. If you really want to attach the file then why don't you simply use PHPMailer included in WHMCS? In pseudo-code it would be something like this. <?php // Require the autoloader require 'vendor/phpmailer/phpmailer/PHPMailerAutoload.php'; // Get the necessary data from tblconfiguration $conf = GetWHMCSConfig(array('CompanyName', 'Email', 'MailType', 'SMTPHost', 'SMTPUsername', 'SMTPPassword', 'SMTPort')); // $conf->CompanyName would be your Company Name set in WHMCS. Same goes for Email, MailType etc. Don't forget to Decrypt($conf->SMTPPassword) $mail = new PHPMailer; $mail->Port = $conf->SMTPort; $mail->Username = $conf->SMTPUsername; $mail->Password = Decrypt($conf->SMTPPassword); // ... and all the usual stuff... $mail->Subject = 'Accept this contract'; $mail->MsgHTML('Please sign your name in blood'); // ... attach your file and... $mail->Send(); // Done 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted March 20, 2019 Share Posted March 20, 2019 This has to be done via the database; $ClientFile = Capsule::table('tblclientsfiles') ->insert( array('userid'=>1, "title"=> "The great file", 'filename'=>"greatfile.doc", 'dateadded'=>date('Y-m-d')) ); Filename should be a file within the attachments directory. I also have heard that the filename needs to be prefixed with "file6DigitNumber" where "6DigitNumber" is a random number but I don't think that is 100% required. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.