Skip to content

Commit 5074629

Browse files
committed
Add SMTP secure option in config to handle yahoo mail
1 parent 71a9800 commit 5074629

File tree

7 files changed

+50
-3
lines changed

7 files changed

+50
-3
lines changed

includes/YesWiki.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
require_once 'includes/constants.php';
66
require_once 'includes/urlutils.inc.php';
7+
require_once 'includes/email.inc.php';
78
require_once 'includes/i18n.inc.php';
89
require_once 'includes/YesWikiInit.php';
910
require_once 'includes/YesWikiPerformable.php';

includes/YesWikiInit.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,15 @@ public function getConfig($wakkaConfig = [])
230230
'root_page' => 'PagePrincipale', // backup root_page if deleted from wakka.config.php
231231
'wakka_name' => '', // backup wakka_name if deleted from wakka.config.php
232232
'htmlPurifierActivated' => false, // TODO ectoplasme set to true
233-
'favorites_activated' => true,
233+
'favorites_activated' => true,
234234
ArchiveService::PARAMS_KEY_IN_WAKKA => [
235235
ArchiveService::KEY_FOR_HIDE_CONFIG_VALUES => ArchiveService::DEFAULT_PARAMS_TO_ANONYMIZE,
236236
'authorize_bypass_preupdate_backup' => false,
237237
'preupdate_backup_activated' => true,
238238
'call_archive_async' => true,
239239
ArchiveService::KEY_FOR_PRIVATE_FOLDER => ArchiveService::PRIVATE_FOLDER_NAME_IN_ZIP,
240240
'max_nb_files' => 10,
241-
],
241+
]
242242
];
243243
unset($_rewrite_mode);
244244

@@ -297,6 +297,9 @@ public function getConfig($wakkaConfig = [])
297297
$wakkaConfig['wikini_version'] = $wakkaConfig['wakka_version'];
298298
}
299299

300+
if (empty ($wakkaConfig ['mail_domain']??null))
301+
$wakkaConfig ['mail_domain'] = \getMailDomain (parse_url($wakkaConfig ['base_url'])['host']);
302+
300303
if (!empty($wakkaConfig['extra_headers'])) {
301304
foreach ($wakkaConfig['extra_headers'] as $header) {
302305
header($header);
@@ -331,6 +334,7 @@ public function initCoreServices($wiki)
331334
// "TODO put elsewhere" - old comment in YesWiki::LoadExtensions -> PUT IN YesWikiInit::initCoreServices - @YvesGufflet
332335
$fullDomain = parse_url($wiki->Href());
333336
$containerBuilder->setParameter('host', $fullDomain['host']);
337+
$containerBuilder->setParameter('mail_domain', $wiki->config ['mail_domain']);
334338
$containerBuilder->setParameter('max-upload-size', $wiki->file_upload_max_size());
335339

336340
return $containerBuilder;

includes/email.inc.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ function send_mail($mail_sender, $name_sender, $mail_receiver, $subject, $messag
4242
$mail->Username = $GLOBALS['wiki']->config['contact_smtp_user'];
4343
//Password to use for SMTP authentication
4444
$mail->Password = $GLOBALS['wiki']->config['contact_smtp_pass'];
45+
46+
$vSMTPSecure = $GLOBALS['wiki']->config['contact_smtp_secure']??null;
47+
48+
if (empty ($vSMTPSecure)) $vSMTPSecure = getSMTPSecure ($mail->Port??null);
49+
50+
switch ($vSMTPSecure)
51+
{
52+
case "ssl" :
53+
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
54+
break;
55+
case "tls" :
56+
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
57+
break;
58+
}
4559
} else {
4660
$mail->SMTPAuth = false;
4761
}
@@ -116,3 +130,27 @@ function send_mail($mail_sender, $name_sender, $mail_receiver, $subject, $messag
116130
return false;
117131
}
118132
}
133+
134+
function getMailDomain ($pHost)
135+
{
136+
$vHost = preg_replace('/^www\./', '', $pHost);
137+
$vParts = explode('.', $vHost);
138+
$vDomain = implode('.', array_slice($vParts, -2));
139+
140+
return $vDomain;
141+
}
142+
143+
function getSMTPSecure ($pPort = null)
144+
{
145+
if (!empty($pPort))
146+
{
147+
switch ($pPort)
148+
{
149+
case "465" : return "ssl";
150+
case "587" : return "tls";
151+
}
152+
}
153+
154+
return "";
155+
}
156+

includes/urlutils.inc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,4 @@ function getAbsoluteURLForLinkInAPage($pPageAbsoluteURL, $pLink)
216216

217217
return $vAbsolutePath;
218218
}
219+

tools/bazar/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ parameters:
55
# Envoi automatique de mail aux admins ?
66
BAZ_ENVOI_MAIL_ADMIN: false
77
# Definition d'un mail par defaut, car il y peut y avoir envoi de mail aux utilisateurs avec la constante suivante
8-
BAZ_ADRESSE_MAIL_ADMIN: 'noreply@%host%'
8+
BAZ_ADRESSE_MAIL_ADMIN: 'noreply@%mail_domain%'
99
# Choix du look du template par défaut $GLOBALS['wiki']->config['default_bazar_template']
1010
default_bazar_template: 'liste_accordeon.tpl.html'
1111
# Si un formulaire est sémantique et qu'il a un des contextes ci-dessous, nous allons chercher dans

tools/contact/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ parameters:
44
contact_smtp_port: "" # port smtp utilisé
55
contact_smtp_user: "" # utilisateur smtp
66
contact_smtp_pass: "" # mot de passe smtp
7+
contact_smtp_secure: "" # smtp secure (ssl,tls,...)
78
contact_use_long_wiki_urls_in_emails: false # add 'wiki=' in url
89
contact_reply_to: "" # default mail to reply to
910
contact_debug: 0 # debug mode (0 pour rien, 1 pour normal, 2 pour détaillé)
@@ -16,6 +17,7 @@ parameters:
1617
- "contact_smtp_port"
1718
- "contact_smtp_user"
1819
- "contact_smtp_pass"
20+
- "contact_smtp_secure"
1921
- "contact_from"
2022
- "contact_reply_to"
2123
- "contact_debug"

tools/contact/lang/contact_fr.inc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
'EDIT_CONFIG_HINT_CONTACT_SMTP_PORT' => 'Port SMTP (généralement 465 ou 587)',
100100
'EDIT_CONFIG_HINT_CONTACT_SMTP_USER' => 'Utilisateur SMTP (souvent le mail)',
101101
'EDIT_CONFIG_HINT_CONTACT_SMTP_PASS' => 'Mot de passe SMTP',
102+
'EDIT_CONFIG_HINT_CONTACT_SMTP_SECURE' => 'Sécurisation de la connexion',
102103
'EDIT_CONFIG_HINT_CONTACT_FROM' => 'Utilisateur indiqué comme émetteur du mail (pour éviter les spams doit être le même que l\'utilisateur smtp)',
103104
'EDIT_CONFIG_HINT_CONTACT_REPLY_TO' => 'Utilisateur auquel la réponse mail sera envoyée',
104105
'EDIT_CONFIG_HINT_CONTACT_DEBUG' => 'Mode verbeux pour débugguer (mettre 2 pour avoir des informations)',

0 commit comments

Comments
 (0)