Linphone Activate an Account by E-Mail

Embed the Flexisip Account Manager(XMLRPC Server) offered by Belledonne Communications into the SIP telephony system composed of the docker containers I have already introduced. As a result, it enables to register users directly via Android Linphone app. It will be the independent system apart from the default Linphone server, only the owner of the system enables to manage own users. Use it for the home interphone system, or adopt it for educational institutions, online communications among limited users like pupils, teachers and curators will be safe.
Backend for the user management has recently introduced, but I am now on verification of it.
This blog content introduce the followings
- A. Asign the customized XMLRPC Server(Account Manager) via Linphone remote configuration.
- B. The user registry of inputting a user name, a password and an email address via Linphone create account menu.
- C. Mail account activation
A: Nothing changed to load the customized XML file by default. So, has to change the XMLRPC server, must rebuild Linphone to change the customized XMLRPC server.
B: Change to the SMS user registry to the email user registry.
C: SMS activation by default as it costs, changing to the activation by email used Gmail SMTP will be free.
The System for Introduction
Flexisip-Account-Manager: https://gitlab.linphone.org/BC/public/flexisip-account-manager
Install it to the PHP-FPM container in the following system composed of other docker ontainers.
Introduction Process
1. Introduction for docker system
1-1. Introduce the account manager in the docker-compose file
1-2. Configure the php-fpm container
1-3. Configure the nginx container
1-4. Create the detabase and tables for user account
1-5. Configure the flexisip.conf for soci
2. Custom build for Linphone on Android Studio
2-1. Modify the build configuration files of Linphone
2-2. Build Linphone
2-3. Install customized Linphone
3. Modify the files of Flexisip Account Manager
3-1. Remote configuration
3-2. Introduce PHPMailer
3-3. Create the php file for email activation
4. Final Confirmation
4-1. Load the remote configuration file
4-2. User registry and email activation
1. Introduction for docker system
It has already written in the following forum(Japanese only)
https://ficus-forum.myvnc.com/t/topic/344
Share the files of the flexisip account manager between php-fpm and nginx containers in the docker-compose file created when it constructed the flexisip server.
1-1. Introduce the account manager in the docker-compose file
Add shared volumes for flexisip-account-manager at the sections of nginx and php-fpm in the docker-compose file for flexisip.
Note) Cleared all settings of above containers after restarting the docker-compose, you need to reinstall additional packages for these.(# marked lines shows these)
# nginx, additional install $ docker exec nginx apk add bash nano
nginx:
container_name: nginx
image: nginx:alpine
tty: true
environment:
- VIRTUAL_HOST=test.site.com
- VIRTUAL_ROOT=/var/www/html
- VIRTUAL_PORT=80
# - VIRTUAL_PROTO=fastcgi
- LETSENCRYPT_HOST=test.site.com
- LETSENCRYPT_EMAIL=testsite@gmail.com
volumes:
# shared nginx default.conf between host and container
- ./nginx_default.conf:/etc/nginx/conf.d/default.conf
# shared the directory /var/www/html in php-fpm container
- ./html:/var/www/html/register
# shared the directory /var/www/html in phpmysql-fpm container
- ./phpmyadmin_data:/var/www/html/phpmyadmin
# for flexisip-account-manager
- ./flexisip-account-manager:/var/www/html/flexisip-account-manager
external_links:
- nginx-proxy-letsencrypt
restart: always
networks:
proxy-tier:
ipv4_address: 172.18.0.6
# php-fpm, additional install $ docker exec php-fpm apk add bash nano
# php extension mysqli should be installed, $ docker exec php-fpm docker-php-ext-install mysqli
# for Userfrosting, install followings.
# apk add libpng-dev freetype-dev libjpeg-turbo-dev zip
# docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
# docker-php-ext-install -j$(nproc) gd
# docker-php-ext-install -j$(nproc) pdo pdo_mysql
# docker-php-ext-install -j$(nproc) zip
php-fpm:
container_name: php-fpm
image: php:7.2-fpm-alpine
tty: true
expose:
- "9000"
volumes:
- ./html:/var/www/html/register
# for flexisip-account-manager. install # apk add libxml2-dev, # docker-php-ext-install xmlrpc
- ./flexisip-account-manager:/var/www/html/flexisip-account-manager
- ./etc/flexisip-account-manager:/etc/flexisip-account-manager
depends_on:
- flexisip-mariadb
restart: always
networks:
proxy-tier:
ipv4_address: 172.18.0.7
Download flexisip-account-manager by git clone command in the directry you like.
$ git clone https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
Copy the files and directries in the src and the conf folders to flexisip-account-manager and etc/flexisip-account-manager respectively.
.
1-2. Configure the php-fpm container
Move into php-fpm container by bash command and install extensions and packages required on XMLRPC server. After installation restart php-fpm container.
$ docker exec -ti php-fpm bash
# apk add libxml2-dev
# docker-php-ext-install xmlrpc
# exit
Restart php-fpm container
$ docker container restart php-fpm
1-3. Configure the nginx container
Add the subdirectory section for flexisip-account-manager into the nginx config file in nginx container.
$ docker exec -ti nginx bash
# nano /etc/nginx/conf.d/default.conf
location ^~ /flexisip-account-manager {
alias /var/www/html/flexisip-account-manager/xmlrpc;
try_files $uri $uri/ @flexisip-account-manager;
location ~ \.php$ {
fastcgi_split_path_info ^\/flexisip-account-manager\/(.+\.php)(.*)$;
fastcgi_param HTTPS 'on';
fastcgi_pass php-fpm:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
}
location @flexisip-account-manager {
rewrite /flexisip-account-manager/(.*)$ /flexisip-account-manager/xmlrpc.php;
}
Reload nginx config
# nginx -s reload
1-4. Create the detabase and tables for user account
In advance, in the following files;
/etc/flexisip-account-manager/db.conf
/var/www/html/flexisip-account-manager/database/database.php
assign the host name, database, username and password.
db.conf
define("DB_HOST", "mariadb-flexisip");
define("DB_USER", "flexisip");
define("DB_PASSWORD", "your_password");
define("DB_NAME", "flexisip");
database.php
"mysql:host=flexisip-mariadb;dbname=flexisip"
Implement the following php script to create tables for user account in php-fpm container.
$ docker exec -ti php-fpm bash
# php /var/www/html/flexisip-account-manager/tools/create_tables.php
(Refference) Query for each table
accounts CREATE TABLE `accounts` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
`domain` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`activated` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0',
`confirmation_key` varchar(14) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`ip_address` varchar(39) COLLATE utf8mb4_unicode_ci NOT NULL,
`user_agent` varchar(256) COLLATE utf8mb4_unicode_ci NOT NULL,
`creation_time` datetime NOT NULL,
`expire_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `identity` (`username`,`domain`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
aliases CREATE TABLE `aliases` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`account_id` int(11) unsigned NOT NULL,
`alias` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
`domain` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `identity` (`alias`,`domain`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
devices CREATE TABLE `devices` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`manufacturer` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
`model` varchar(34) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(34) COLLATE utf8mb4_unicode_ci NOT NULL,
`delay` int(4) NOT NULL DEFAULT 0,
`hardware_echo_canceller` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
passwords CREATE TABLE `passwords` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`account_id` int(11) unsigned NOT NULL,
`password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`algorithm` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'MD5',
PRIMARY KEY (`id`),
UNIQUE KEY `account` (`account_id`,`algorithm`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
sms CREATE TABLE `sms` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`phone` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`last_sms` bigint(15) unsigned DEFAULT 0,
`count` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `phone` (`phone`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
user_info CREATE TABLE `user_info` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`account_id` int(11) unsigned NOT NULL,
`firstname` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL,
`lastname` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL,
`gender` enum('male','female') COLLATE utf8mb4_unicode_ci NOT NULL,
`country_code` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`country_name` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`subscribe` enum('0','1') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
1-5. Configure the flexisip.conf for soci
As the account table doesn't include password colum and the passwords table is independent in flexisip-account-manager database, change the section of soci in flexisip.conf to extract a password from the account table.
/etc/flexisip/flexisip.conf
soci-password-request=select passwords.password, 'SHA-256' from accounts inner join passwords on accounts.id=passwords.account_id where username = :id and domain = :domain
2. Custom build for Linphone on Android Studio
To valid the email activation and change XMLRPC server, rebuild Linphone on Android Studio.
2-1. Modify the build configuration files of Linphone
After downloading Linphone for Android with git clone command, open Linphone project. The files should be modified are followings:
non_localizable_custom.xml, default_assistant_create.rc, linphone_assistant_create.rc, linphonerc_factory
Please also check the below site about these files.
non_localizable_custom.xml
Write down only modified sections.
Change the default domain, invalid SMS activation and valid mandatory email activation.
If you need more, add additional changes.
<?xml version="1.0" encoding="utf-8"?>
<resources>
............................
<!-- URLs, URIs and domain -->
<!-- Set the default domain used for account creation/addresses -->
<string name="default_domain" translatable="false">sip.example.com</string>
<string name="default_stun" translatable="false">sip.example.com:3478</string>
............................
<!-- Phone numbers -->
<bool name="use_phone_number_validation">false</bool><!-- Use phone number for validation -->
.............................
<!-- Set the email field of the wizard with one of the gmail account registered on the device -->
<bool name="pre_fill_email_in_assistant">true</bool>
<bool name="assistant_account_validation_mandatory">true</bool>
........................
</resources>
default_assistant_create.rc
Delete the section "<entry name="domain" overwrite="true"></entry>" to load other XMLRPC server from remote configuration menu on Linphone.
..............
<section name="assistant">
<entry name="algorithm" overwrite="true">MD5</entry>
<entry name="password_max_length" overwrite="true">-1</entry>
<entry name="password_min_length" overwrite="true">0</entry>
<entry name="username_length" overwrite="true">-1</entry>
<entry name="username_max_length" overwrite="true">128</entry>
<entry name="username_min_length" overwrite="true">1</entry>
<entry name="username_regex" overwrite="true">^[a-zA-Z0-9+_.\-]*$</entry>
</section>
.....
linphone_assistant_create.rc
Change SIP server and STUN server loaded by default. But if not changed these sections, you could change these on Linphone app.
Delete the section "<entry name="domain" overwrite="true">sip.linphone.org</entry>" to load other XMLRPC server from remote configuration menu on Linphone.
<section name="proxy_default_values">
...............................................
...............................................
<entry name="reg_identity" overwrite="true">sip:?@sip.example.com:5071</entry>
<entry name="reg_proxy" overwrite="true"><sip:sip.example.com:5071;transport=tls></entry>
<entry name="reg_route" overwrite="true"><sip:sip.example.com:5071;transport=tls></entry>
..............................................
<entry name="realm" overwrite="true">sip.example.com</entry>
..............................................
</section>
<section name="nat_policy_default_values">
<entry name="stun_server" overwrite="true">sip.example.com:3478</entry>
...............................................
</section>
<section name="assistant">
<entry name="algorithm" overwrite="true">SHA-256</entry>
<entry name="password_max_length" overwrite="true">-1</entry>
<entry name="password_min_length" overwrite="true">1</entry>
<entry name="username_length" overwrite="true">-1</entry>
<entry name="username_max_length" overwrite="true">64</entry>
<entry name="username_min_length" overwrite="true">1</entry>
<entry name="username_regex" overwrite="true">^[a-z0-9+_.\-]*$</entry>
</section>
linphonerc_factory
Delete the following section to set other XMLRPC servers via remote configuration on Linphone.
[assistant]
xmlrpc_url=https://subscribe.linphone.org:444/wizard.php
2-2. Build Linphone
Implement Build--->APK(s) to create APK file.
Build--->Clear Project follows Build--->Build APK(s) to rebuild.
2-3. Install customized Linphone
Download APK file into your Android mobile, accept to install from 3rd party app.
3. Modify the files of Flexisip Account Manager
Set XML file in the provisioning field of the remote configuration, you can modify the Linphone setting.
The provisioning is for adding or deleting the functions for sound and video essentially.
But to manage users under own database, have the provisioning change XMLRPC server.
3-1. Remote configuration
Valid overwriting configurations by the remote provisioning.
etc/provisioning.conf
<?php
/*
* If set to True, each section will be flagged as overwrite, otherwise none of them will be flagged.
*
* Default value: False
*/
define("REMOTE_PROVISIONING_OVERWRITE_ALL", True);
/*
* The path to a default linphone rc file to add to the generated remote provisioning
* If using the default value, the default.rc file should be created in /opt/belledonne-communications/share/flexisip-account-manager/xmlrpc/ directory
* If the file does not exists it is ignored
*
* The file should follow the lpconfig format, for example:
* [sip]
* rls_uri=sips:rls@sip.linphone.org
* # This is a commentary, it won't appear in the generated xml provisioning
*
* Default value: "default.rc"
*/
define("REMOTE_PROVISIONING_DEFAULT_CONFIG", "default.rc");
/*
* The default transport to set in the proxy config if not specified
* Can be "tls", "tcp" or "udp"
*
* Default value: "tls"
*/
define("REMOTE_PROVISIONING_DEFAULT_TRANSPORT", "tls");
?>
Write down the domain and XMLRPC server address in xmlrpc/default.rc.
#
#This file shall not contain path referencing package name, in order to be portable when app is renamed.
#Paths to resources must be set from LinphoneManager, after creating LinphoneCore.
[assistant]
domain=sip.example.com
xmlrpc_url=https://sip.example.com/flexisip-account-manager/xmlrpc.php
Assign the file "https://sip.example.cpm/flexisip-account-manager/provisioning.php" made from "xmlrpc/default.rc" in the field of the remote provisioning to overwrite config.
Assign the XML file directly in the provisioning field.
The address for provisioning:https://sip.example.cpm/flexisip-account-manager/provisioning.xml
xmlrpc/provisionong.xml
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://www.linphone.org/xsds/lpconfig.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.linphone.org/xsds/lpconfig.xsd lpconfig.xsd">
<section name="assistant">
<entry name="domain" overwrite="true">sip.example.com</entry>
<entry name="xmlrpc_url" overwrite="true">https://sip.example.com/flexisip-account-manager/xmlrpc.php</entry>
</section>
</config>
3-2. Introduce PHPMailer
For mail activation, introduce PHPMailer with using Gmail SMTP server.
https://github.com/PHPMailer/PHPMailer
In advance, modify the email configration file to valid sending a mail function and change or add messages to be sent.
etc/emails.conf
<?php
/* ### Email configuration ### */
/*
* Whever or not enable the send email feature.
* Used to send link to generate random password if user forgot it, or the newly generated email once the link has been clicked.
*
* Default value: False
*/
define("EMAIL_ENABLED", True);
/*
* The website address to display in the email header.
*
* Default value: https://linphone.org
*/
define("EMAIL_SITE", "https://sip.example.com");
/*
* The link to open when click on activation
* It can have a %key%, %username% and %algo% parameter
*
* Default value: www.linphone.org
*/
define("EMAIL_ACTIVATION_LINK", "sip.example.com/flexisip-account-manager/mail_activate.php?key=%key%&username=%username%&algo=%algo%");
/*
* The FROM address to set in the email header.
*
* Default value: no.reply@linphone.org
*/
define("EMAIL_FROM_ADDR", "example.com@gmail.com");
/*
* The FROM display name to set in the email header.
*
* Default value: No reply at Linphone.org
*/
define("EMAIL_FROM_NAME", "No reply at Ficusonline");
/*
* The subject of the activation account email.
*/
define("EMAIL_ACTIVATION_SUBJECT", "Start your Ficusonline Linphone SIP service");
/*
* The body (as text) of the activation account email.
*/
define("EMAIL_ACTIVATION_BODY", "Hello,\nActivation pending for using your Ficusonline Linphone account.\nPlease use the link bellow to activate your account :\n\n%link%\n\nRegards,\nThe Linphone team.\n");
/*
* The body (as html) of the activation account email.
*/
define("EMAIL_ACTIVATION_BODY_HTML", '<html><head><title>Start your Ficusonline Linphone SIP service</title></head><body><p>Hello,</p><p>Activation pending for using your Linphone account.
<br />Please use the link bellow to activate your account :</p><p><a href="%link%">%link%</a></p><p> </p><p>Regards,<br />The Linphone team.</p></body></html>');
/*
* The subject of the account recovery email.
*/
define("EMAIL_RECOVERY_SUBJECT", "Recover your Ficusonline Linphone SIP account");
/*
* The body (as text) of the account recovery email.
*/
define("EMAIL_RECOVERY_BODY", "Hello,\nHere is your recovery code: %key%\n\nRegards,\nThe Ficusonline Linphone team.\n");
/*
* The body (as html) of the account recovery email.
*/
define("EMAIL_RECOVERY_BODY_HTML", '<html><head><title>Recover your Ficusonline Linphone SIP account</title></head><body><p>Hello,</p><p>Here is your recovery code: %key%</p><p>Regards,
<br />The Ficusonline Linphone team.</p></body></html>');
?>
Install PHPMailer in flexisip-account-manager directory by Composer.
Implement the following command in root directory of the server(XMLRPC server).
$ sudo composer require phpmailer/phpmailer
Change "function send_email" to meet PHPMailer with Gmail SMTP.
xmlrpc/email.php
<?php
/*
Flexisip Account Manager is a set of tools to manage SIP accounts.
Copyright (C) 2019 Belledonne Communications SARL, All rights reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//Import PHPMailer classes into the global namespace
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
include_once __DIR__ . '/../config/config.php';
include_once __DIR__ . '/../misc/logging.php';
function send_email($email, $subject, $text, $html) {
require '../vendor/autoload.php';
$site = EMAIL_SITE;
$from = EMAIL_FROM_ADDR;
$name = EMAIL_FROM_NAME;
$to = $email;
// $from = $name." <".$from.">";
$limite = "_----------=_parties_".md5(uniqid (rand()));
// $headers = "Reply-to: ".$from."\n";
// $headers .= "From: ".$from."\n";
// $headers .= "Return-Path: ".$from."\n";
// $headers .= "X-Sender: <".$site.">\n";
// $headers .= "X-Mailer: PHP\n";
// $headers .= "X-auth-smtp-user: ".$from." \n";
// $headers .= "X-abuse-contact: ".$from." \n";
// $headers .= "Date: ".date("D, j M Y G:i:s O")."\n";
// $headers .= "MIME-Version: 1.0\n";
//$headers .= "Content-Type: multipart/alternative; boundary=\"".$limite."\"";
$message = "";
$message .= "--".$limite."\n";
$message .= "Content-Type: text/plain; charset=\"utf-8\"\n";
$message .= "Content-Transfer-Encoding: 8bit\n\n";
$message .= $text;
$message .= "\n\n--".$limite."\n";
$message .= "Content-Type: text/html; charset=\"utf-8\"\n";
$message .= "Content-Transfer-Encoding: 8bit;\n\n";
$message .= $html;
$message .= "\n--".$limite."--";
// $params = "-f" . EMAIL_FROM_ADDR . " -O DeliveryMode=b";
// $result = mail($email, $subject, $message, $headers, $params);
// if (!$result) {
// Logger::getInstance()->error("[EMAIL] Email delivery declined !");
// }
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// SMTP::DEBUG_OFF = off (for production use)
// SMTP::DEBUG_CLIENT = client messages
// SMTP::DEBUG_SERVER = client and server messages
$mail->SMTPDebug = SMTP::DEBUG_OFF;
//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
// use
// $mail->Host = gethostbyname('smtp.gmail.com');
// if your network does not support SMTP over IPv6
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587;
//Set the encryption mechanism to use - STARTTLS or SMTPS
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = 'example.com@gmail.com';
//Password to use for SMTP authentication
$mail->Password = 'xxxxxxxxxxx';
//Set who the message is to be sent from
$mail->setFrom($from, 'Ficusonline');
//Set an alternative reply-to address
$mail->addReplyTo('ficus.online@gmail.com', 'Ficusonline');
//Set who the message is to be sent to
$mail->addAddress($to, 'to registry user');
//Set the subject line
$mail->Subject = $subject;
$mail->addCustomHeader('Content-Type: multipart/alternative; boundary="'.$limite.'"');
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
//$mail->msgHTML(file_get_contents('contents.html'), __DIR__);
//An HTML or plain text message body.
//If HTML then call isHTML(true).
$mail->isHTML(true);
$mail->Body = $message;
//Replace the plain text body with one created manually
//$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$result=$mail->send()) {
//echo 'Mailer Error: '. $mail->ErrorInfo;
Logger::getInstance()->error("[EMAIL] Email delivery declined !");
} else {
Logger::getInstance()->debug("[EMAIL] Email sent: result= " . $result);
//echo 'Message sent!';
//Section 2: IMAP
//Uncomment these to save your message in the 'Sent Mail' folder.
#if (save_mail($mail)) {
# echo "Message saved!";
#}
}
}
3-3. Create the php file for email activation
After the user registration on the create account page, sent the message including the link for activation.
For activattion by clicking the link, need to create a new php file.
A return value is SHA-256 password, so should be change it you like.
mail_activate.php
<?php
/*
Flexisip Account Manager is a set of tools to manage SIP accounts.
Copyright (C) 2019 Belledonne Communications SARL, All rights reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
include_once __DIR__ . '/xmlrpc.php';
$username = $_GET['username'];
$key = $_GET['key'];
$algo = $_GET['algo'];
$method = "activate_email_account";
$params = array ($username, $key, "sip.example.com", $algo);
$request = xmlrpc_encode_request($method, $params, array('output_type' => 'xml','encoding' => 'utf-8'));
// echo $request;
// $options = array('output_type' => 'xml', 'version' => 'auto');
echo xmlrpc_server_call_method($server, $request, null);
?>
4. Final Confirmation
4-1. Load the remote configuration file
Assistant---->Remote configuration--->Input provisioning address:
https://sip.example.cpm/flexisip-account-manager/provisioning.php
or, input the xml file you cretated.
https://sip.example.cpm/flexisip-account-manager/provisioning.xml
Restart Linphone to load the changes.
4-2. User registry and email activation
Input an username, a password and an email address to register on Assistant Create Account page.
Click the link in the messages of the mail sent to your email address to activate your account.
After that, push the button of "Finish Configuration"
I will follow about this contents in the forum site.