Jump to content

API sendemail


ChrisTERiS

Recommended Posts

Hello,

Even if on the API documentation for SendEmail it marks as Optional the field id (The related id for the type of email template. Eg this should be the client id for a general type email), I assume that is a typo. But I gave a try by adding 'email' => 'myemail@mydomain.com', or 'customemail' => 'myemail@mydomain.com' without any luck.

What I want to know is if there is a way to send an email, like the one that system send for contact form message, using API. I mean when I can pass as parameter only an email address and not any id.

Thank you

Chris

 

Link to comment
Share on other sites

The sendmail API function expects the client id, as in the number, and not the email.   For service messages, it would be the service id -- again the number and not the  username or domain. 

If you are wanting to send to an address that isn't a client, a support ticket might be a better option though likely not what you want.   I don't think there is a method to send to a specific address otherwise. 

Link to comment
Share on other sites

@steven99 Thank you. This is what I understood, but I had a hope that maybe I missed something from the API documentation. Don't know why they don't add an API call to send general emails. Actually is easy to bypass this limitation in 3 easy steps, I tried and it worked fine, but don't like to use it. All 3 with API calls

  1. Create a Client and get clientid
  2. Send the message with that clientid
  3. Delete the Client
Link to comment
Share on other sites

I am curious, why would you want to send an email to someone that isn't already a client from a system for clients?   I think doing a new ticket would be your best bet here, even if you do not use the built-in ticket system.  Open the ticket via api, close the ticket via api,   Mail still goes out to them. 

Link to comment
Share on other sites

9 minutes ago, steven99 said:

I am curious, why would you want to send an email to someone that isn't already a client from a system for clients?   I think doing a new ticket would be your best bet here, even if you do not use the built-in ticket system.  Open the ticket via api, close the ticket via api,   Mail still goes out to them. 

Good question and I'll reply if you promise that you'll not laugh 🙃

To avoid loading phpmailer, templates, and replacing variables 🤪

Link to comment
Share on other sites

20 hours ago, WHMUp said:

To avoid loading phpmailer, templates, and replacing variables 🤪

That's exactly what you are supposed to do. There is no other way.

p.s. I prefer to use phpmailer also for customers due to API limitations. It's 2021 and I still can't remove/add attachments 😐

Link to comment
Share on other sites

2 hours ago, Kian said:

p.s. I prefer to use phpmailer also for customers due to API limitations. It's 2021 and I still can't remove/add attachments 😐

I'm self teached so API was (and still is), just a word with general meaning. But I like the fact that I was able to do some simple things with just 5-6 lines of code.

Same with hooks, something that appears to be like a piece of cake for you, looking in your great collection of hooks. My congratulations.

 

 

 

Link to comment
Share on other sites

9 hours ago, steven99 said:

@WHMUp did you look at doing the open ticket and then closing it I mentioned earlier?   Check https://developers.whmcs.com/api-reference/openticket/ for opening the ticket. 

Hello Steven,

Yes, I did, and thank you for your advice. But there is a dark point on this. As this task is part of a module and not for my own use, I don't know if webmaster has setup any support department. Sure I can query database to find it, but in this case the code goes much longer.

As you can see I've  a setting for the module where the webmaster will choose to use a support ticket or use standard emailing. For that standard emailing option I wanted the API call.

image.thumb.png.51ccaacc3244669ed7d05a2d91ca714d.png

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