BryanB Posted June 14, 2011 Share Posted June 14, 2011 I developed a custom page and I'd like to send an email template to the client once that page is submitted. I don't really want to use the invoice ID, as the invoice has nothing to do with what we are doing, its really just based on the order ID or the client ID... The API documentation isn't very clear and it sounds like you have to use an invoice or service ID (not entirely sure what the service id is either). We simply want to send an email template to a certain client ID when I a custom page is submitted. Is this possible & how? Also, can email templates contain custom PHP code? Thanks! 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted June 16, 2011 Share Posted June 16, 2011 The ID variable in the API will accept a client ID, service ID, invoice, etc. Just make sure the template that you create is a "General" template if you plan to use the client id. Heres a quick code example from within WHMCS: $apiuser = 'user_with_api_access'; $template = 'Name of Your Template'; $clientid = '100'; $action = 'sendemail'; $data = array('messagename'=>$template, 'id'=>$clientid); $result = localApi($action, $data, $apiuser); if ($result['result'] != 'success') { print 'ERROR: '.$results['result']; } else { print 'Mail sent successfully'; } 0 Quote Link to comment Share on other sites More sharing options...
BryanB Posted June 16, 2011 Author Share Posted June 16, 2011 awesome. that should work. thank you. 0 Quote Link to comment Share on other sites More sharing options...
kimhoo Posted July 25, 2011 Share Posted July 25, 2011 Breaking my head on this one. Is there also a way to send an e-mail in an order context via API? It seems as if I can only pass a clientid, but I need a custom order confirmation. I've place my custom order e-mail in the general category, but that doens't seem to work. The e-mail is send in the client's context and not aware of any order just created. Second question and related, wouldn't it be more logical to have the addorder action to support an alternative email template, instead of only noemail option? 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted July 26, 2011 Share Posted July 26, 2011 The template you create needs to be a product template I believe, in order to attach it to an invoice ID, not a general. I'm not sure what you mean by your second question. You can specify any template you want to send when an order is placed. You do not need to do any custom coding to make that work. 0 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.