Jump to content

sendMessage Help


dkaczmark

Recommended Posts

I have a module in place and I need it to send an email message after at the end.

 

I currently have

 

sendMessage("Welcome Email",$userid);

 

Where "Welcome Email" is a general message. It's not returning or sending anything, however. I've tried many different combinations of template names, and id's, but nothing will send.

 

Any ideas would be greatly appreciated.

Link to comment
Share on other sites

  • 1 month later...

I'm walking the same road. Documentation is sketchy here, but the way I am reading this function, the first parameter is the name of a template in your Admin Email Templates. The value of the second parameter depends on which message group your template is in.

 

Matt posted that in the domains group, it should be the domain id.

Another said that in the invoice group, use the invoice id.

For me, in the "Product Messages" group (where the welcome emails are located), tblhosting.id seems to be working, so far.

 

Good luck.

Link to comment
Share on other sites

The sendMail code works similar to the send email api commnad.

 

http://wiki.whmcs.com/API:Send_Email

 

The id is relevant to the specific category you sending mail from. As said above if its in the domain group it should be the domain id. If its a general message it should be the client id. Ect...

 

Remember you have to include in both the dbconnect file ({WHMCSROOT}/dbconnect.php) and the function file ({WHMCSROOT}/includes/functions.php) for this command to work correctly.

 

Happy developing!

Link to comment
Share on other sites

  • 4 weeks later...

There are a few ways to use the sendMessage function. General emails, product emails, domain emails.

The first argument is the template name, the second is the id that relates to the product or user, the third is an array of variables used to replace the smarty variables in the template.

 

Sample Template:

Name: "Sample Template"

Hello {$client_name},
This message is to test {$dummy_variable}...
{$signature}

sendMessage('Sample Template',$userid,array('dummy_variable' => 'Sending Emails via the sendMessage function'));

Link to comment
Share on other sites

Hi,

 

is there a way to use sendMessage() for outgoing emails, that don't have a client/product/domain connection?

 

E.g. I would need to call it like this:

 

sendMessage('Private Auction Invitation', $email_address, $auction_infos);

 

Where $email_address is a plain email address, not an index. It's ok if these message don't get stores in tblemails.

 

Best,

-jens

Link to comment
Share on other sites

Hi,

 

is there a way to use sendMessage() for outgoing emails, that don't have a client/product/domain connection?

 

E.g. I would need to call it like this:

 

sendMessage('Private Auction Invitation', $email_address, $auction_infos);

 

Where $email_address is a plain email address, not an index. It's ok if these message don't get stores in tblemails.

 

Best,

-jens

 

sendMessage is a WHMCS function, I've only figured out how to use it and it appears that it requires a template name, userid or product id and array of replacement variables to work.

Link to comment
Share on other sites

I know, and it works fine! What I need is a way to send email to an email address that is not assigned to a client.

 

E.g. a domain registrant has an email address which is different from the client account managing the domain, and you need to send an email directly to the registrant.

Link to comment
Share on other sites

// require_once('../../../includes/class.phpmailer.php');

try {

$mailer = new PHPMailer(); // defaults to using php "mail()"

$mailer->AddAddress ($ToEmailAddress, "");

$mailer->SetFrom ($FromEamilAddress, $FromDisplayName);

$mailer->Subject = $Subject;

$mailer->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mailer->MsgHTML ($message);

$mailer->Send();

 

} catch (phpmailerException $e) {

$errors .= $e->errorMessage() . "<BR />"; //Pretty error messages from PHPMailer

} catch (Exception $e) {

$errors .= $e->getMessage() . "<BR />"; //Boring error messages from anything else!

}

 

 

I use this code to fire of an email from inside a server module.

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

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