Jump to content

Email Template import / export


ipgeek-lg

Recommended Posts

Hi, first post so here goes,

 

I have developing an addon module for whmcs and have come across a problem. Part of the addons functionality involves sending an email or two out to clients. The problem I am having is using the _activate function to run an sql query to put pre-defined email templates into the DB.

 

So far I have the following for the query:

 

$sqlEmail1 = "INSERT INTO `tblemailtemplates` (`type`, `name`, `subject`, `message`, `attachments`, `fromname`, `fromemail`, `disabled`, `custom`, `language`, `copyto`, `plaintext`) 
VALUES ('general', 'IPGeek - Custom Email 1', 'Password Reset', 'Some text that contains {$company_name} among other things', '', '', '', '', '1', '', '', 0)"

 

Now the problem with this is using " to contain the SQL query with {$company_name} in it makes php try to insert the previously defined variable {$company_name} when actually running the SQL query.

 

I could change to 'INSERT.... but this then means using ' to contain field values ('Password Reset') would not be a possibility.

 

Anyone got any ideas?

Link to comment
Share on other sites

--UPDATE--

Tried using the insert_query() function to no avail:

 

$table = "tblemailtemplates";
$values = array("type"=>"general","name"=>"IPGeek - First Email","subject"=>"Password Reset","message"=>'{$company_name} among other things.</p>',"custom"=>"1","plaintext"=>0);
$newid = insert_query($table,$values);

Link to comment
Share on other sites

--UPDATE--

 

Managed to do this with the help of some guys over at StackOverflow:

 

$email_templates = "INSERT INTO `tblemailtemplates` (`type`, `name`, `subject`, `message`, `attachments`, `fromname`, `fromemail`, `disabled`, `custom`, `language`, `copyto`, `plaintext`)
VALUES ('general', 'IPGeek Security - PWRESET - First Email', 'Password Reset', '<p>Dear {\$client_name}</p><p>A request has been received by {\$company_name} for your account password to be reset. If you did not initiate this request then please get in contact with our support department.</p>', '', '', '', '', '1', '', '', 0)";
$result = mysql_query($email_templates);

 

So the $ was escaped and we are able to use " to enclose the SQL query.

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