Jump to content

How to show conditional content in Welcome Email based on specific config options chosen


bluesteam

Recommended Posts

Hello

I am reselling VPS servers and these servers can either have cPanel or DirectAdmin as a panel choice.

So I'm trying to create a welcome email that will display the cPanel URL details or the DirectAdmin url details based on whichever panel they chose during checkout.

I have the following choices for  the client:

DirectAdmin Personal
DirectAdmin Lite
DirectAdmin Standard
cPanel (5 Accounts)
cPanel (30 Accounts)
cPanel (50 Accounts)

So if the client chooses any of the DirectAdmin options, then display the DirectAdmin content and the same applies for any cPanel option chosen to show the cPanel info.

I have the following code:

{if $service_config_options|strstr:'DirectAdmin'}

DirectAdmin Access
=============================
http://{$service_dedicated_ip}:2222/

{else}

WHM Access
=============================
http://{$service_dedicated_ip}:2087/

{/if}

But everytime I try sending the email, I get this error:

image.png.4f95347f4963cc2e9311c1bcaac60864.png

 

So I'm not sure what could be wrong with my syntax because it looks ok to me.

Anyone have any ideas??

Link to comment
Share on other sites

30 minutes ago, bluesteam said:

Anyone have any ideas??

I think you might be running into any of 4 issues... any one of which would probably prevent the email from sending (certainly the last one will)....

  1. in the email template, view the content via the "View Source" window just to ensure WHMCS hasn't added any crap to your coding (can occur if you just copy&paste code straight in).
    UH3cAvH.png
  2. i'm sure $service_config_options is an array, so you couldn't check if in the way you're trying to - you should try using $service_config_options_html instead.
  3. I would suggest trying the PHP format of using strstr...
    {if strstr("DirectAdmin",$service_config_options_html)}yes{else}no{/if}

    i've had success with using that method in the email templates in the past... so try change yes/no above to your output.

  4. if you're using v8 or later, then you're going to be running into everyone's favourite feature, Smarty Security Policy, where virtually every PHP function is disabled in the emails by default. 🙄
    so if you're going to use strstr in the templates, you're going to have to modify the policy in your confuration.php file...

    $smarty_security_policy = array(
        'mail' => array(
            'php_functions' => array(
                'strstr',
            ),
        ),
    );

as I said at the start, the policy is likely going to be the main issue, so i'd start with that and then work your way through the other three.

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