Merge pull request #474 from LDAPAccountManager/feature/465_email2sms

Feature/465 email2sms
This commit is contained in:
gruberroland 2025-09-17 19:42:27 +02:00 committed by GitHub
commit 221811b7e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 137 additions and 1 deletions

View file

@ -1,3 +1,8 @@
December 2025 9.4
- LAM Pro:
-> SMS sending can be done with email2SMS providers (465)
16.09.2025 9.3
- New translation: Greek
- Tree view: added comparison feature (440)

View file

@ -345,6 +345,28 @@
</listitem>
</itemizedlist>
<para><emphasis role="bold">Email2SMS</emphasis></para>
<para>This service can be used for all SMS gateways that allow to send
SMS via email. This means LAM sends out an email to the gateway and they
convert it to an SMS.</para>
<itemizedlist>
<listitem>
<para>Account id: please enter the receiving email address at your
email2SMS gateway. The address must contain the wildcard "$number"
for the user's phone number. E.g. "$number@sms.clicksend.com".
"$number" will be replaced with the actual mobile phone
number.</para>
</listitem>
<listitem>
<para>From: this is the email FROM address. Typically, email2SMS
gateways require that the email comes from a specific email
address.</para>
</listitem>
</itemizedlist>
<para><emphasis role="bold"><ulink
url="https://gatewayapi.com/">GatewayAPI</ulink></emphasis></para>

View file

@ -1536,7 +1536,7 @@ function sendEMail($to, $subject, $text, $from, $isHTML, $replyTo = null, $cc =
include_once __DIR__ . '/3rdParty/composer/autoload.php';
$returnPath = empty($replyTo) ? $from : $replyTo;
$returnPathParsed = PHPMailer\PHPMailer\PHPMailer::parseAddresses($returnPath);
logNewMessage(LOG_DEBUG, "Send mail to " . print_r($to, true) . "\n" . $text);
logNewMessage(LOG_DEBUG, "Send mail from " . $from . " to " . print_r($to, true) . "\n" . $text);
$mailer = new PHPMailer\PHPMailer\PHPMailer(true);
try {
$cfgMain = $_SESSION['cfgMain'];

View file

@ -0,0 +1,109 @@
<?php
namespace LAM\PLUGINS\SMS;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2025 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
use LAMException;
/**
* Email2SMS provider.
*
* @author Roland Gruber
*/
/**
* Email2SMS provider.
*
* @package LAM\PLUGINS\SMS
*/
class Email2SmsProvider implements SmsProvider {
/**
* @inheritDoc
*/
public function getLabel(): string {
return 'EMail2SMS';
}
/**
* @inheritDoc
*/
public function getId(): string {
return 'email2sms';
}
/**
* @inheritDoc
*/
public function sendSms(string $message, string $number, ?string $apiKey = '', ?string $apiToken = '',
?string $accountId = '', ?string $region = '', ?string $from = ''): void {
if (str_starts_with($number, '+')) {
$number = '00' . substr($number, 1);
}
$to = str_replace('$number', $number, $accountId);
$success = sendEMail($to, '', $message, $from, false);
if ($success) {
logNewMessage(LOG_DEBUG, 'Email2Sms sent to ' . $to);
}
else {
logNewMessage(LOG_ERR, 'Unable to send SMS via Email2SMS for ' . $to);
throw new LAMException(null, '');
}
}
/**
* @inheritDoc
*/
public function usesApiToken(): bool {
return false;
}
/**
* @inheritDoc
*/
public function usesApiKey(): bool {
return false;
}
/**
* @inheritDoc
*/
public function usesAccountId(): bool {
return true;
}
/**
* @inheritDoc
*/
public function usesFrom(): bool {
return true;
}
/**
* @inheritDoc
*/
public function usesRegion(): bool {
return false;
}
}