Jump to content

Sending Emails via API


BryanB

Recommended Posts

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!

Link to comment
Share on other sites

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';
}

Link to comment
Share on other sites

  • 1 month later...

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?

Link to comment
Share on other sites

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.

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