Jump to content

Api to sendemail can not sent template, only custom variables

Recommended Posts

Hi, I'm needed to send me an email from api, a template defined in the system related to invoices

My API code to send emails works well, but only if you use custom variables, such as subject, body, etc. But I want to send an email template that I have in the whmcs

According to https://developers.whmcs.com/api-reference/sendemail/ , in order to indicate to the API that the ID = IS ONE INVOICE ID, I must define

$ postfields ["customtype"] = "invoice";

Then there I can say:

$ postfields ["id"] = (int) $ invoiceId; // here is my id To be able to send the information related to the invoice.

But I just define it:

["customtype"] = "invoice"
["messagename"] = "New Tax Invoice generated"; // this is the system template.

the api gives error me

1. Answer: Answer: {"result": "error", "message": "A subject is required for a personalized message"} //
2. Answer: {"result": "error", "message": "A body of the message is required for a personalized message"} //

I do not want a personalized message or a personalized SUBJECT. I just want to send my messagename (template)

I repeat that i dont want to use custommessage , customsubject or customvars. I just want to send the whmcs template related to the invoice.


Share this post

Link to post
Share on other sites

I found it !!!

I dont have to define

["customtype"] = "invoice"

only with this lines works !!

	$postfields["messagename"] = "Nueva Factura Fiscal generada";
        $postfields["id"] = (int)$invoiceId;


Share this post

Link to post
Share on other sites

Yes, once you add any of the custom fields, besides customvars, it handles the request as a complete custom message. 

Share this post

Link to post
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.

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