ChrisTERiS Posted February 7, 2021 Share Posted February 7, 2021 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 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted February 9, 2021 Share Posted February 9, 2021 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. 1 Quote Link to comment Share on other sites More sharing options...
ChrisTERiS Posted February 10, 2021 Author Share Posted February 10, 2021 @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 Create a Client and get clientid Send the message with that clientid Delete the Client 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted February 12, 2021 Share Posted February 12, 2021 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. 0 Quote Link to comment Share on other sites More sharing options...
ChrisTERiS Posted February 12, 2021 Author Share Posted February 12, 2021 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 🤪 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted February 13, 2021 Share Posted February 13, 2021 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 😐 0 Quote Link to comment Share on other sites More sharing options...
ChrisTERiS Posted February 13, 2021 Author Share Posted February 13, 2021 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. 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted February 13, 2021 Share Posted February 13, 2021 @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. 0 Quote Link to comment Share on other sites More sharing options...
ChrisTERiS Posted February 14, 2021 Author Share Posted February 14, 2021 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. 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.