All posts by neutrinus

Beat Caveng, Developer bei A-Enterprise GmbH. Blog Author zu den Themen, Python und Open Source. Tutorials zu Python Problemlösungen und Shell Scripts.

Grandstream UCM LDAP Phonebook

This article descries the central phonebook provisioning using LDAP on a UCM IP PBX, allowing users to save, retrieve and make calls from their own contacts.

GRANDSTREAM UCM6202 UCM6208 central phonebook for contacts

The existing Phonebook of the UCM is intended for PBX, these contacts cannot be added or deleted directly. To change contacts, go to “Extensions” in the WebUI of the UCM. The read-only attributes of the corresponding elements can be edited in the extensions. The phone book is automatically updated when changes are made to the extensions. To add external contacts, users can use additional phonebooks. For these phone books, LDAP attributes can be edited and contacts can be added or deleted directly.

For the LDAP Phonebook already pre-installed on the UCM. You create an additional phone book, here in this example it is mycontacts, the X.500 Context looks like this:

ou=mycontacts,dc=pbx,dc=com

The configuration for phone books can be found in the WebUI of the UCM under System Settings – LDAP Server – LDAP Phonebook:

Click on +Add and create a new phonebook:

After saving, the newly created phonebook appears as follows. The prefix denotes the X.500 Distinguished Name (DN) as an object OU=mycontacts:

On the right you click on the editor icon to add new contacts:

With the phone GXP21xx you go to PHONEBOOK and LDAP:

In the Server Address field you enter the IP of the UCM. In the Field Base the context, under Phonebook – LDAP: (ou=mycontacts,dc=pbx,dc=com)

For the provisioning of the LDAP Phonebook mycontacts you go to Value-added-Features – Zero Config – Global Policy and open Contact List and activate Directory under LDAP Phonebook. Then you select the previously created Phonebook at Source, here mycontacts:

Now Zero Config will make the change for the phones by clicking update.

On the phone GXP21xx you press the directory button and select LDAP directory, you have to enter a character at min. before pressing the softkey search, e.B. with an A all contacts containing an A are listed.

send mail mailx command

Send e-mail in the terminal shell using mail or mailx command

Sending e-mail in command line from a server is very useful, for example, when performing e-mail from shell scripts or web applications.

send e-mail in the command line

This tutorial shows how to use the mail and mailx command on Linux to send e-mail from the command line. We use the Heirloom mailx project that is a collection of traditional Unix utilities.

How to use the mail command on Fedora

For this to be possible, with the mailx package, often also mailutils, they must be present on the host, the deployment on Fedora and CentOS is as follows:

sudo yum install -y mail

Using mailx utility on Debian/Ubuntu

For Debian and Linux Mint or other Debian forkes, the following apt-get command can be performed:

sudo apt-get install heirloom-mailx

The CLI command mail is now applicable in the shell:

mail -s "Hello World" email@example.com

When you try to send an e-mail, you will probably get an error first!

No configuration file found at /home/joe/.esmtprc or /etc/esmtprc

The error is solved by creating the esmtprc configuration file, using vi or nano or the editor of choice:

vi /.esmtprc

Add an SMTP gateway, which allows us to accept e-mail from our host.

hostname = smtp.example.com:25

This configuration allows the user to send e-mail through smtp.example.com. If all users are to be authorized, the /etc/esmtprc file must be created and edited.

Is there another mistake! a relay host must be allowed:

SMTP server problem Connection refused

Set up a postfix smtp relay

Emails should be accepted by our host, e.g. gateway smtp.example.com forward 25 e-mails over TCP port.

On the SMTP gateway, if it is postfix, the main configuration have to modify, to do it will use sudo with edit main.cf.

sudo vi /etc/postfix/main.cf

For mynetworks, the host IP or hostname that is allowed to send emails is added.

mynetworks =
        127.0.0.0/8
        [::1]/128
        192.168.2.3

In this example, 192.168.2.3 is our host to be sent from this email.

Apply changes of the Postfix main configuration:

sudo postfix reload

Example: Send e-mail in the command-line

echo "message here" | mail -s "subject" email@example.com < dump.sql.gz

Sending a previously created SQL dump should be delivered after the backup.

subnet=" (ip -4 a | grep inet | grep -v 'virbr' | grep -v 'docker' | awk ''print'' | grep -v '127.0.0.1')"; ipcalc "Asubnet" | mail -s "ssubnet" hostmaster@example.com

Here the IPv4 configuration is determined with the command ip, it is attempted to filter out the virtual interfaces by grep and awk.

ifconfig | grep -Eo 'inet (addr:)?([0-9] *.) {[0-9]3}*' | grep -Eo [0-9]'(*') {[0-9]3}*' | grep -v '127.0.0.1' | mail -s "ifconfig" hostmaster@example.com

ifconfig is the traditional command, but newer distributions require the net-utils package to be installed.

hostnamectl | mail -s "my host" email@domain.com

The hostnamectl command provides useful information, available on newer Linux versions.

more related in this post

Heirloom mailx is a mail user agent for Unix systems. Highlights are:

Derived from Berkeley Mail 8.1. An interface like the original Berkeley one is still optionally available. Is a free implementation of the System V mailx command and features an interface like that by default.

Is intended to comply to the mailx command specifications of IEEE Std 1003.2-1992 (POSIX.2) and IEEE Std 1003.1-2004 with XSI extensions (SUSv3). Supports the MIME specifications. Mailx command can send mail and receive attachments and code and decode international character strings.

If the system libraries provide appropriate support, conversion between different character encodings is performed. In combination with a UTF-8 terminal, nearly all international languages are supported. External converter programs can be automatically invoked e. g. to view messages in HTML format. Supports IMAP.

In combination with either OpenSSL or Mozilla NSS, IMAPS can also be used. With IMAP, folder hierarchies can be stored and managed on remote servers. This is particularly useful for people who use more than one computer to access their mail. Of course, it is also possible to use IMAP just for fetching mails and storing them locally.

Supports caching and disconnected operation of IMAP folders.

This speeds up operation while in online mode. It also makes it possible to transparently view and edit IMAP mailboxes without an active connection to the server. Supports POP3 to read messages on a remote server. In combination with OpenSSL or NSS, POP3S can also be used. Mailx can read and delete individual messages, thus POP3 accounts can almost be accessed like local mail folders.

Supports SMTP to send messages directly to a remote server.

A local sendmail interface setup is thus not necessary. In combination with OpenSSL or NSS, both the STARTTLS method and SMTPS can be used. SMTP AUTH is also supported. Supports S/MIME for signed and encrypted email (in combination with OpenSSL or NSS). In combination with NSS, certificates for S/MIME and SSL/TLS can be shared with Mozilla applications, and can be managed using them.

Can display message threads and supports operations on them. This is especially useful for handling mailing lists. It is also possible to sort messages by various other criteria. Provides a Bayesian junk mail filter mostly according to Paul Graham’s article “Better Bayesian Filtering”.

Chained tokens according to Jonathan A. Zdziarski’s “Advanced Language Classification using Chained Tokens” can optionally be used. Features a lot of detail improvements over previous implementations of Mail/mailx, such as IMAP-style search methods and flags for any types of folders, killing and scoring of messages, maildir folder support, an option to set the From: address directly, and the generation of References:

header fields to avoid annoyances on mailing lists. Can be used as a mail batch language in nearly the same way as it is used interactively. So it is possible to use mailx as a mailbox filter, for fetching mails, or for sending files as attachments. Is extensively described in its manual page mailx(1), which provides both introductory material and complete reference documentation.