Variables for message email

mr.suchy

Verified User
Joined
Oct 1, 2015
Messages
24
Hi,

Where is list with all variable which I can use in welcome message ex. |bandwidth|

Kind regards
 

MaXi32

Verified User
Joined
Jul 25, 2016
Messages
547
Location
The Earth
This has been asked before, https://forum.directadmin.com/threads/dumptokens-list.62429/ (it's not easy to get this variable), it is not well documented.

Since the OP was talking about welcome template (since that old time), For now, I can only think of 2 ways how to get this

1) using the welcome template with |DUMPTOKENS| (https://help.directadmin.com/item.php?id=2114)

***WARNING, for this method, I must warn you that, you should not add |DUMPTOKENS| on a live template (such as welcome message), you might end up sending a lot personal information FROM THE DUMPTOKENS to your users. Don't be scared with this warning if you know what you are doing. Anyway if you want to continue:

First edit this (for user welcome message)

nano /usr/local/directadmin/data/users/admin/u_welcome.txt

and add this magic token |DUMPTOKENS| inside that a_welcome.txt to get all list of variables (put it on top):

Code:
|DUMPTOKENS|

Dear Customer,
TOKEN:



        Thank you for choosing our service to meet your web hosting needs.


Your account has been created with the following details:


Username:       |username|
Password:       |password|
Domain:         |domain|



Now, use ur working email to add a new user and you need to provide your email, to see the dump message:


The output you got from email might be like this:


Code:
OWNED=no
PORT=2222
SERVERNAME=yest.test.com
account=ON
additional_bandwidth=0
aftp=ON
api_with_password=yes
bandwidth=unlimited

and more ...
Code:


Now you can test this variable inside your welcome email. Done, you can remove the |DUMPTOKENS| variable from the template.


2nd way

I' m not so sure if the pre hook script variable can also be used with the template (need confirmation). so, if you want to get these variable, you can do the following:

1) So, before user is created, we are interested with the hook call user_create_pre.sh

2) We can create this pre script here (Directadmin 1.60+ ways):

mkdir -p /usr/local/directadmin/scripts/custom/user_create_pre

nano /usr/local/directadmin/scripts/custom/user_create_pre/dump.sh

Inside this file, paste the following script:


Code:
#!/bin/bash

script_path="$(dirname "$(readlink -f "$0")")"
script_name=$(basename -- "$0")
echo "The name of this script is: ${script_name}"
echo "==========="
env >"${script_path}/${script_name}.env"
echo "==========="
echo "The script ${script_name} has finished executed"

Make it executable:

chmod +x dump.sh

Now, create a new user and a new file called dump.env will be generated with many variables. To view the dumped variables you can do this:


cat /usr/local/directadmin/scripts/custom/user_create_pre/dump.env

Again for the second step, I'm not sure if some variables are actually compatible with the template but you can test them to see the correct output.
 
Last edited:

twv

Verified User
Joined
Oct 31, 2003
Messages
207
Thanks, very helpful!

I added |DUMPTOKENS| to the welcome email. Here are the fields it added:

OWNED
PORT
SERVERNAME
account
additional_bandwidth
aftp
api_with_password
bandwidth
catchall
cgi
creator
cron
date_created
dnscontrol
docsroot
domain
domainptr
email
ftp
inode
ip
language
login_keys
mysql
name
nemailf
nemailml
nemailr
nemails
notify_on_all_question_failures
notify_on_all_twostep_auth_failures
ns1
ns1ip
ns2
ns2ip
nsubdomains
package
password
php
quota
security_questions
skin
spam
ssh
ssl
suspend_at_limit
suspended
sysinfo
twostep_auth
username
usertype
vdomains
zoom
 
Top