dkaczmark Posted October 26, 2010 Share Posted October 26, 2010 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. 0 Quote Link to comment Share on other sites More sharing options...
rwsmr Posted December 22, 2010 Share Posted December 22, 2010 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. 0 Quote Link to comment Share on other sites More sharing options...
jeremyhaber Posted December 22, 2010 Share Posted December 22, 2010 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! 0 Quote Link to comment Share on other sites More sharing options...
tsiedsma Posted January 14, 2011 Share Posted January 14, 2011 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')); 0 Quote Link to comment Share on other sites More sharing options...
hexonet Posted January 14, 2011 Share Posted January 14, 2011 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 0 Quote Link to comment Share on other sites More sharing options...
tsiedsma Posted January 14, 2011 Share Posted January 14, 2011 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. 0 Quote Link to comment Share on other sites More sharing options...
hexonet Posted January 14, 2011 Share Posted January 14, 2011 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. 0 Quote Link to comment Share on other sites More sharing options...
rwsmr Posted January 15, 2011 Share Posted January 15, 2011 // 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. 0 Quote Link to comment Share on other sites More sharing options...
hexonet Posted January 19, 2011 Share Posted January 19, 2011 Thank you! I'll try to build a function around it, so I can use the smarty based email templates. Best, -jens 0 Quote Link to comment Share on other sites More sharing options...
gcphost Posted March 3, 2011 Share Posted March 3, 2011 Do you have to include anything for "sendmessage"? I am using it in a module but am having issues using it in a hook. 0 Quote Link to comment Share on other sites More sharing options...
hexonet Posted March 17, 2011 Share Posted March 17, 2011 Hi, afaik you need to include dbconnect.php and includes/functions.php require("dbconnect.php"); require("includes/functions.php"); Best, -jens 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.