Skip to content

Commit 2ffc8f8

Browse files
authored
Add check if email is valid (hestiacp#2944)
1 parent 4eac6fb commit 2ffc8f8

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

install/upgrade/manual/configure-server-smtp.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function setupFiles
4040
read -i $SERVER_SMTP_USER -e smtp_server_user_name
4141
echo "Enter SMTP Password (stored as plaintext):"
4242
read -i $SERVER_SMTP_PASSWD -e smtp_server_password
43-
echo "Enter SMTP Address:"
43+
echo "Enter Email Address:"
4444
read -i $SERVER_SMTP_ADDR -e smtp_server_addr
4545
else
4646
use_smtp=false
@@ -53,7 +53,7 @@ function setupFiles
5353
SMTP Security: $smtp_server_security
5454
SMTP Username: $smtp_server_user_name
5555
SMTP Password: $smtp_server_password
56-
SMTP Address: $smtp_server_addr
56+
Email Address: $smtp_server_addr
5757
Are these values correct? (y/N)"
5858
read correct_validation
5959
correct="${correct_validation:-n}"

web/inc/main.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,11 @@ function send_email($to, $subject, $mailtext, $from, $from_name, $to_name = '')
404404
$mail = new PHPMailer();
405405

406406
if (isset($_SESSION['USE_SERVER_SMTP']) && $_SESSION['USE_SERVER_SMTP'] == "true") {
407-
$from = $_SESSION['SERVER_SMTP_ADDR'];
407+
if(!empty($_SESSION['SERVER_SMTP_ADDR']) && $_SESSION['SERVER_SMTP_ADDR'] != ''){
408+
if(filter_var($_SESSION['SERVER_SMTP_ADDR'], FILTER_VALIDATE_EMAIL)){
409+
$from = $_SESSION['SERVER_SMTP_ADDR'];
410+
}
411+
}
408412

409413
$mail->IsSMTP();
410414
$mail->Mailer = "smtp";

0 commit comments

Comments
 (0)