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?

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?
Comments
https://docs.whmcs.com/Email_Templates#Custom_PHP_Logic
https://developers.whmcs.com/hooks-reference/everything-else/#emailpresend
EDIT:
@niels, beat me to it >.<
Worst documentation ever.
@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...
I can give it a try sometime but will take some time as being occupied for > a week.
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
Smarty. Funtastic.
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.
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
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
You can just send me a virtual kiss, I want it recorded though.
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.
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.
..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.
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?
@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
)
You probably don't want to alow forwarding <1024 ports.
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.
I also pitty the fool who sends me html mails.
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.