Walther Posted October 6 Share Posted October 6 I need to send an email message to my customer and, in cc, to a couple of different foreign email addresses. But it seems to be impossible... The API SendEmail command ( https://developers.whmcs.com/api-reference/sendemail ) allows you to specify just the user ID, and send te message to the email address of that user ID... but does not allow tospecify any CC or CCN address (note. this is possible when you send a message from the WHMCS admin web interface, so it's not a limit of the system but just of the API function). I tried using the PreEmailSendReduceRecipients hook, but it allows just to remove a predefined CC recipient, not to add a new one or redefiny an existing one... Any ideaabout how to do it? 0 Quote Link to comment Share on other sites More sharing options...
Waqas Ahmed Waseer Posted 11 hours ago Share Posted 11 hours ago Ran into the same wall when we wanted a client's accountant copied on billing mails. You're right about the hooks: EmailPreSend can only add merge fields, attach files or abort the send, and PreEmailSendReduceRecipients can only remove CC/BCC entries, never add them. So it has to come from the recipient side. Three ways, depending on how fixed the extra addresses are: 1. Same extra addresses every time: create a custom email template (General type) under Configuration > System Settings > Email Templates and fill in its CC and BCC fields. Then call SendEmail with messagename set to that template and id set to the client ID. Every send of that template copies those addresses. 2. Addresses that belong to one client (their accountant, a partner, a second mailbox): add them as Contacts on that client and enable the matching email preferences (General, Invoice, Support and so on). WHMCS copies contacts on emails of the types they're opted into, and that's exactly the cc list PreEmailSendReduceRecipients receives. It also works for a custom message via SendEmail with customtype=general. 3. Different addresses on every send: from your script call AddContact with email_preferences[general]=1, then SendEmail, then DeleteContact. A bit hacky, but the message still lands in the client's email log. If you don't need it logged in WHMCS at all, send that one through your own SMTP (PHPMailer etc.) outside the API. Whichever you pick, test it on a dummy client first and check the Email Log to confirm the CC line looks the way you expect. 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.