diff --git a/interface/web/login/lib/lang/ar.lng b/interface/web/login/lib/lang/ar.lng
index f7cb6ea03a9c07b4367cd790aef29bdc8398e354..74e4c49ecd6e5d5814db4045e0e769fc6833ff72 100644
--- a/interface/web/login/lib/lang/ar.lng
+++ b/interface/web/login/lib/lang/ar.lng
@@ -46,4 +46,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/bg.lng b/interface/web/login/lib/lang/bg.lng
index 1d44e64d5579e1c56954bc7c8fabcb08cfc7fa94..6d6f92c87371215a299b51eb15ed9aa3bed719a5 100644
--- a/interface/web/login/lib/lang/bg.lng
+++ b/interface/web/login/lib/lang/bg.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/br.lng b/interface/web/login/lib/lang/br.lng
index 4b2040fa217d68966cd71b6bdbd18f16f1802dd7..e8df8f25dce2c777d8d2f64242a909eade9fbca9 100644
--- a/interface/web/login/lib/lang/br.lng
+++ b/interface/web/login/lib/lang/br.lng
@@ -39,3 +39,4 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
diff --git a/interface/web/login/lib/lang/ca.lng b/interface/web/login/lib/lang/ca.lng
index eb8a189931a801993eea22a7d359671a9302717b..0895c1df492e48bef35305d5f1bb608067669b91 100644
--- a/interface/web/login/lib/lang/ca.lng
+++ b/interface/web/login/lib/lang/ca.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/cz.lng b/interface/web/login/lib/lang/cz.lng
index dff3646bf6390efa449c117e3f5a1a55d6dd0bd8..8089dcc5fc79cee78c588374c26431c5136d70f4 100644
--- a/interface/web/login/lib/lang/cz.lng
+++ b/interface/web/login/lib/lang/cz.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/de.lng b/interface/web/login/lib/lang/de.lng
index 08dedddcacbb0e235f254dc80cdc865f3bbcbc37..6c8472fe7602b3368701a8b38bbfe7823901d22c 100644
--- a/interface/web/login/lib/lang/de.lng
+++ b/interface/web/login/lib/lang/de.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/dk.lng b/interface/web/login/lib/lang/dk.lng
index b039450cc5d31e81a4906bb8f066148fc14e499f..b971e10bd6a514b12714dfed6a8f88babbc84160 100644
--- a/interface/web/login/lib/lang/dk.lng
+++ b/interface/web/login/lib/lang/dk.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/el.lng b/interface/web/login/lib/lang/el.lng
index ee415bac81a5531eaf77312afca49b64effcdbcd..578b342c5e26bbae3cb12ff42fe5910e1d7205ff 100644
--- a/interface/web/login/lib/lang/el.lng
+++ b/interface/web/login/lib/lang/el.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/en.lng b/interface/web/login/lib/lang/en.lng
index d27b880fd9f5bd2550da8f7684a9cd3f17ef351d..405e320500dba4b3a7e366db25d46fc027b8bcd4 100644
--- a/interface/web/login/lib/lang/en.lng
+++ b/interface/web/login/lib/lang/en.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/es.lng b/interface/web/login/lib/lang/es.lng
index 641acc09175540d30d5bc58286c77ac5882384e3..a6da15296e76f729c7232f1daf80cd6cd413c017 100644
--- a/interface/web/login/lib/lang/es.lng
+++ b/interface/web/login/lib/lang/es.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/fi.lng b/interface/web/login/lib/lang/fi.lng
index 939187f03ecb239af600ccd12d7f236d846bcc30..496383401b426e00ea6289aa20b8828ff4e2eb7d 100644
--- a/interface/web/login/lib/lang/fi.lng
+++ b/interface/web/login/lib/lang/fi.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/fr.lng b/interface/web/login/lib/lang/fr.lng
index dad6c367c23f9d3003374457c72e1a35f81df7fb..e8104aacaaa738ecde30f0292e8f1b86a235c452 100644
--- a/interface/web/login/lib/lang/fr.lng
+++ b/interface/web/login/lib/lang/fr.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/hr.lng b/interface/web/login/lib/lang/hr.lng
index 7acfdda363794547be991d0eb4214f6091e06ff9..ae20203acdd490204d22a1f467523623fcc7852e 100644
--- a/interface/web/login/lib/lang/hr.lng
+++ b/interface/web/login/lib/lang/hr.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/hu.lng b/interface/web/login/lib/lang/hu.lng
index 9f0ba953c743bca2ea3685d1337c3955a3eadf6b..f8ad853a4888c3401ff9c1e7249ec834cd20a3ef 100644
--- a/interface/web/login/lib/lang/hu.lng
+++ b/interface/web/login/lib/lang/hu.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/id.lng b/interface/web/login/lib/lang/id.lng
index 311ed123a73c5f08b1169f7385b7ae4893a39919..fb0ba69e37b12c79a359d79ac737e37372dd54a6 100644
--- a/interface/web/login/lib/lang/id.lng
+++ b/interface/web/login/lib/lang/id.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/it.lng b/interface/web/login/lib/lang/it.lng
index 2a1f2582b8e60095f100266f4e789d632e016b4f..4ea0a12f4b215aa13507d990a62638fc08187647 100644
--- a/interface/web/login/lib/lang/it.lng
+++ b/interface/web/login/lib/lang/it.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/ja.lng b/interface/web/login/lib/lang/ja.lng
index 4940d14b0ac79a23ec52789e0ea7385c7f0cdd0e..8ec65a03e355b74b55d97902cd4a287ebd43e6fe 100644
--- a/interface/web/login/lib/lang/ja.lng
+++ b/interface/web/login/lib/lang/ja.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/nl.lng b/interface/web/login/lib/lang/nl.lng
index 3e328c06d67c5f47a92caa7727345843e543f3b0..2a3fc75eea6efdab99bb5356aaeba70010691f20 100644
--- a/interface/web/login/lib/lang/nl.lng
+++ b/interface/web/login/lib/lang/nl.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/pl.lng b/interface/web/login/lib/lang/pl.lng
index f4ca20cc25a1ab9f3a83c9e164d0ba061dd75b81..2a037016f775bca290ee6d26b849c5d45eb3dcf9 100644
--- a/interface/web/login/lib/lang/pl.lng
+++ b/interface/web/login/lib/lang/pl.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/pt.lng b/interface/web/login/lib/lang/pt.lng
index 491e8225d14f308b06d453808f3bdc342098b40c..b7eb8a26632559743a6217c6b86340e06c59c4d6 100644
--- a/interface/web/login/lib/lang/pt.lng
+++ b/interface/web/login/lib/lang/pt.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/ro.lng b/interface/web/login/lib/lang/ro.lng
index 5f8532ea253473051047f34ed1255782f8c82584..21ba4da975d9150a356ebdd10ac3ef717a504064 100644
--- a/interface/web/login/lib/lang/ro.lng
+++ b/interface/web/login/lib/lang/ro.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/ru.lng b/interface/web/login/lib/lang/ru.lng
index d1629c92688568f71f10aec6ff90fc6953453cba..e79ac35f10a5e237a54af412e17f76c6daa5ca39 100644
--- a/interface/web/login/lib/lang/ru.lng
+++ b/interface/web/login/lib/lang/ru.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/se.lng b/interface/web/login/lib/lang/se.lng
index acad6e04b6b1cdb0a4f7f184cff56da826843dda..04d81344e26f680a2b1373dfff683499baa5184d 100644
--- a/interface/web/login/lib/lang/se.lng
+++ b/interface/web/login/lib/lang/se.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/sk.lng b/interface/web/login/lib/lang/sk.lng
index 1190e99cf326c5bf756cfeb77e44c706657db2da..28033ff210774f0598f59dec7fb0cebf25ad546a 100644
--- a/interface/web/login/lib/lang/sk.lng
+++ b/interface/web/login/lib/lang/sk.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/lib/lang/tr.lng b/interface/web/login/lib/lang/tr.lng
index f764bdd4496280a54a0578695a39bb9037871453..47be8107b64649d44f42124388140a0a0f465ef6 100644
--- a/interface/web/login/lib/lang/tr.lng
+++ b/interface/web/login/lib/lang/tr.lng
@@ -39,4 +39,5 @@ $wb['otp_code_email_sent_txt'] = 'An email was sent to';
 $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
 $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
 $wb['otp_code_resend_txt'] = 'Request new code';
+$wb['otp_code_email_sent_failed_txt'] = 'Failed sending an email to %s';
 ?>
diff --git a/interface/web/login/otp.php b/interface/web/login/otp.php
index 543ded4a44809a94778f789f4678d3aee9d93488..66381d29471991db99b85cc54f8399fd2da05c33 100644
--- a/interface/web/login/otp.php
+++ b/interface/web/login/otp.php
@@ -149,22 +149,30 @@ if($_SESSION['otp']['type'] == 'email') {
 			$mail_config['use_smtp'] = true;
 			$app->ispcmail->setOptions($mail_config);
 		}
-		$email_to = $_SESSION['otp']['data'];
+
+		$clientuser = $app->db->queryOneRecord('SELECT email FROM sys_user u LEFT JOIN client c ON (u.client_id=c.client_id) WHERE u.userid = ?', $_SESSION['s_pending']['user']['userid']);
+		$email_to = $clientuser['email'];
+
 		$app->ispcmail->setSender($mail_config['admin_mail'], $mail_config['admin_name']);
 		$app->ispcmail->setSubject($wb['otp_code_email_subject_txt']);
 		$app->ispcmail->setMailText(sprintf($wb['otp_code_email_template_txt'], $new_otp_code));
 		$send_result = $app->ispcmail->send($email_to);
 		$app->ispcmail->finish();
 
+		if ($send_result) {
 
-		// Increase sent counter.
-		if(!isset($_SESSION['otp']['sent'])) {
-			$_SESSION['otp']['sent'] = 1;
-		} else {
-			$_SESSION['otp']['sent']++;
-		}
-		$token_sent_message = $wb['otp_code_email_sent_txt'] . ' ' . $email_to;
+			// Increase sent counter.
+			if(!isset($_SESSION['otp']['sent'])) {
+				$_SESSION['otp']['sent'] = 1;
+			} else {
+				$_SESSION['otp']['sent']++;
+			}
 
+			$token_sent_message = $wb['otp_code_email_sent_txt'] . ' ' . $email_to;
+		}
+		else {
+			$token_sent_message = sprintf($wb['otp_code_email_sent_failed_txt'], $email_to);
+		}
 	}
 
 	// Show form to enter email code