Browse Source

Added support for no password smtp

Toby Chui 9 months ago
parent
commit
c328082c31
3 changed files with 9 additions and 16 deletions
  1. 9 4
      mod/email/email.go
  2. 0 3
      web/components/streamprox.html
  3. 0 9
      web/components/utils.html

+ 9 - 4
mod/email/email.go

@@ -42,17 +42,22 @@ SendEmail(
 )
 */
 func (s *Sender) SendEmail(to string, subject string, content string) error {
-	//Parse the email content
+	// Parse the email content
 	msg := []byte("To: " + to + "\n" +
 		"From: Zoraxy <" + s.SenderAddr + ">\n" +
 		"Subject: " + subject + "\n" +
 		"MIME-version: 1.0;\nContent-Type: text/html; charset=\"UTF-8\";\n\n" +
 		content + "\n\n")
 
-	//Login to the SMTP server
-	//Username can be username (e.g. admin) or email (e.g. [email protected]), depending on SMTP service provider
-	auth := smtp.PlainAuth("", s.Username, s.Password, s.Hostname)
+	// Initialize the auth variable
+	var auth smtp.Auth
+	if s.Password != "" {
+		// Login to the SMTP server
+		// Username can be username (e.g. admin) or email (e.g. [email protected]), depending on SMTP service provider
+		auth = smtp.PlainAuth("", s.Username, s.Password, s.Hostname)
+	}
 
+	// Send the email
 	err := smtp.SendMail(s.Hostname+":"+strconv.Itoa(s.Port), auth, s.SenderAddr, []string{to}, msg)
 	if err != nil {
 		return err

+ 0 - 3
web/components/streamprox.html

@@ -112,7 +112,6 @@
                     }
                     clearStreamProxyAddEditForm();
                     initProxyConfigList();
-                    $("#addproxyConfig").slideUp("fast");
                 },
                 error: function() {
                     msgbox('An error occurred while processing the request', false);
@@ -269,8 +268,6 @@
                     }
                 });
                 editingStreamProxyConfigUUID = configUUID;
-                $("#addproxyConfig").slideDown("fast");
-
             }else{
                 msgbox("Unable to load target config", false);
             }

+ 0 - 9
web/components/utils.html

@@ -342,15 +342,6 @@
             form.find('input[name="username"]').parent().removeClass('error');
         }
 
-        // validate password
-        const password = form.find('input[name="password"]').val().trim();
-        if (password === '') {
-            form.find('input[name="password"]').parent().addClass('error');
-            isValid = false;
-        } else {
-            form.find('input[name="password"]').parent().removeClass('error');
-        }
-
         // validate sender address
         const senderAddr = form.find('input[name="senderAddr"]').val().trim();
         if (!emailRegex.test(senderAddr)) {