Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


WHMCS E-Mail Templates - No PHP?
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

WHMCS E-Mail Templates - No PHP?

randvegetarandvegeta Member, Host Rep

I though WHMCS support PHP login within their E-Mail templates. Apparently they do not (or I don't know how to do it).

We are about to release our NAT VPS line of servers and everything is ready and setup, with the final part being the E-Mail template.

Normally, the E-Mail template includes the server IP and login credentials, but with NAT VPS, we need to include more information, such as the public address and assigned ports. The ports are allocated according to the IP address so the PHP logic is exceedingly simple.

The idea is that if the private IP is 192.168.0.1, the allocated ports would be 100 - 120. And if the IP is 192.168.0.20, the allocated ports would be 2000-2020 and so on and so forth. This could simply be described in the welcome e-mail but I think it would be nice to have all the details specific to the client already ready, rather than force them to do some maths (no matter how simple it may be).

So I've been trying to put PHP logic into the template like so

{php}

{/php}

Anyone have any ideas?

«1

Comments

  • BlaZeBlaZe Member, Host Rep
    edited December 2017
  • lonealonea Member, Host Rep

    @randvegeta feel free to switch to Blesta and then you'll feel the wrath of Worst documentation ever.

  • randvegetarandvegeta Member, Host Rep

    @lonea said:
    @randvegeta feel free to switch to Blesta and then you'll feel the wrath of Worst documentation ever.

    We use both. And I have had the misfortune of writing modules for Blesta too. And yes indeed, it was terrible documentation. Took me 10x longer to write the same module for Blesta as it did for WHMCS.

    But that documentation for getting PHP logic into the E-mail Templates make no sense (to me).

  • @randvegeta said:

    @lonea said:
    @randvegeta feel free to switch to Blesta and then you'll feel the wrath of Worst documentation ever.

    We use both. And I have had the misfortune of writing modules for Blesta too. And yes indeed, it was terrible documentation. Took me 10x longer to write the same module for Blesta as it did for WHMCS.

    But that documentation for getting PHP logic into the E-mail Templates make no sense (to me).

    Yeah, try to write something for Clientexec...

  • @randvegeta said:

    @lonea said:
    @randvegeta feel free to switch to Blesta and then you'll feel the wrath of Worst documentation ever.

    We use both. And I have had the misfortune of writing modules for Blesta too. And yes indeed, it was terrible documentation. Took me 10x longer to write the same module for Blesta as it did for WHMCS.

    But that documentation for getting PHP logic into the E-mail Templates make no sense (to me).

    I can give it a try sometime but will take some time as being occupied for > a week.

  • @imok said:

    @randvegeta said:

    @lonea said:
    @randvegeta feel free to switch to Blesta and then you'll feel the wrath of Worst documentation ever.

    We use both. And I have had the misfortune of writing modules for Blesta too. And yes indeed, it was terrible documentation. Took me 10x longer to write the same module for Blesta as it did for WHMCS.

    But that documentation for getting PHP logic into the E-mail Templates make no sense (to me).

    Yeah, try to write something for Clientexec....

    Who the fuck still uses clientexec?

  • Oh and a better suggestion.

    Create an app on your domain under any subdirectory like tools which takes ip as input from $_GET

    Show all your php logic and add link in emails as

    https://myhost.com/clients/whatsmyport?ip=192.168.0.1

    Thanked by 2WSS randvegeta
  • Smarty. Funtastic.

    Thanked by 2jetchirag doghouch
  • lonealonea Member, Host Rep
    edited December 2017

    From what I understand from the brief look at it, in order for you to use custom php codes in an email. You need to run it as a hook, then pass the merge_fields to the email template.

    Pretty straight forward I think.

    randvegeta said: We use both. And I have had the misfortune of writing modules for Blesta too. And yes indeed, it was terrible documentation. Took me 10x longer to write the same module for Blesta as it did for WHMCS.

    But that documentation for getting PHP logic into the E-mail Templates make no sense (to me).

  • MikePTMikePT Moderator, Patron Provider, Veteran

    Just hire @jetchirag, guy is good programming whmcs modules, he'll give a look if you pay him a pizza I heard.

    Thanked by 1jetchirag
  • @MikePT said:
    Just hire @jetchirag, guy is good programming whmcs modules, he'll give a look if you pay him a pizza I heard.

    Yum

  • MikePTMikePT Moderator, Patron Provider, Veteran

    @jetchirag said:

    @MikePT said:
    Just hire @jetchirag, guy is good programming whmcs modules, he'll give a look if you pay him a pizza I heard.

    Yum

    See, just got you free dinner, work it out with @randvegeta <3

  • @MikePT said:

    @jetchirag said:

    @MikePT said:
    Just hire @jetchirag, guy is good programming whmcs modules, he'll give a look if you pay him a pizza I heard.

    Yum

    See, just got you free dinner, work it out with @randvegeta <3

    If randvegeta still needs it, we can work it out

    Also, I'd love to share some slices (Not the francisco pony tho) with you :D

    Thanked by 1MikePT
  • MikePTMikePT Moderator, Patron Provider, Veteran

    jetchirag said: If randvegeta still needs it, we can work it out

    Also, I'd love to share some slices (Not the francisco pony tho) with you :D

    You can just send me a virtual kiss, I want it recorded though. <3

  • jetchiragjetchirag Member
    edited December 2017

    @MikePT said:

    jetchirag said: If randvegeta still needs it, we can work it out

    Also, I'd love to share some slices (Not the francisco pony tho) with you :D

    You can just send me a virtual kiss, I want it recorded though. <3

    Stallion would be proud

  • You just need to make a Smarty function and call it from the template, feeding back those variables given. It's not rocket surgery.

  • MikePTMikePT Moderator, Patron Provider, Veteran

    @jetchirag said:

    @MikePT said:

    jetchirag said: If randvegeta still needs it, we can work it out

    Also, I'd love to share some slices (Not the francisco pony tho) with you :D

    You can just send me a virtual kiss, I want it recorded though. <3

    Stallion would be proud

    Sounds sexy.

  • @randvegeta

    I have an idea -- put an HTML image in the email pointing to a PHP script that generates the port information. Have that image take the user to another page, if necessary.

  • @FlamesRunner said:
    @randvegeta

    I have an idea -- put an HTML image in the email pointing to a PHP script that generates the port information. Have that image take the user to another page, if necessary.

    ..and unless they're smart enough to setup/use IPv6 or memorize ports, they're going to open a ticket because they can't find it in the system.

    If standard Smarty functions still exist in template use, you can easily use truncate/substr inine without having to code an actual external function.

  • randvegetarandvegeta Member, Host Rep
    edited December 2017

    @jetchirag said:
    Oh and a better suggestion.

    Create an app on your domain under any subdirectory like tools which takes ip as input from $_GET

    Show all your php logic and add link in emails as

    https://myhost.com/clients/whatsmyport?ip=192.168.0.1

    That's actually brilliant! Takes all of 5 mins to do. A bit ugly but it's not bad.

    Just out of curiosity, how much would it cost to get it done properly?

  • FlamesRunnerFlamesRunner Member
    edited December 2017

    @randvegeta

    What do you mean by properly?

    If you mean a simple PHP script, hell, it's such a simple job that I'd do it free (or for a small VPS, wink wink :p)

  • You probably don't want to alow forwarding <1024 ports.

  • randvegetarandvegeta Member, Host Rep

    FlamesRunner said: What do you mean by properly?

    The PHP script is trivial (5 mins tops). But getting the E-Mails sent out with all the details is what I would prefer. Getting the PHP code to work in the PHP template is not as trivial (for me).

  • Can Smarty interpolate PHP with variables, like IP? Could just explode('.') and multiply/add the last octet.

  • @WSS said:

    @FlamesRunner said:
    @randvegeta

    I have an idea -- put an HTML image in the email pointing to a PHP script that generates the port information. Have that image take the user to another page, if necessary.

    ..and unless they're smart enough to setup/use IPv6 or memorize ports, they're going to open a ticket because they can't find it in the system.

    If standard Smarty functions still exist in template use, you can easily use truncate/substr inine without having to code an actual external function.

    I also pitty the fool who sends me html mails.

  • @hzr said:
    Can Smarty interpolate PHP with variables, like IP? Could just explode('.') and multiply/add the last octet.

    Hi. You can scroll up where I asked the same question, and gave samples of builtins.

  • randvegetarandvegeta Member, Host Rep

    @WSS said:

    @hzr said:
    Can Smarty interpolate PHP with variables, like IP? Could just explode('.') and multiply/add the last octet.

    Hi. You can scroll up where I asked the same question, and gave samples of builtins.

    Not familiar with Smarty. Quick look and it seems rather limited in what it can do.

  • @randvegeta said:

    @WSS said:

    @hzr said:
    Can Smarty interpolate PHP with variables, like IP? Could just explode('.') and multiply/add the last octet.

    Hi. You can scroll up where I asked the same question, and gave samples of builtins.

    Not familiar with Smarty. Quick look and it seems rather limited in what it can do.

    Its' a template engine, and a PHP one at that.

    You can usually pipe data, like {assign name=penis value=$smarty.server.ID}[code]{/assign} sort of deals and use the PHP-builtins. It's not great.

Sign In or Register to comment.