mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-10 23:36:11 +01:00
bug fix: snappymail default to port 993
This commit is contained in:
@@ -59,10 +59,103 @@ class mailUtilities:
|
||||
os.makedirs("/usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/domains/")
|
||||
|
||||
finalPath = "/usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/domains/" + domain + ".ini"
|
||||
finalPathJson = "/usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/domains/" + domain + ".json"
|
||||
|
||||
if not os.path.exists(finalPath):
|
||||
shutil.copy(path, finalPath)
|
||||
|
||||
contentJSON = """
|
||||
{
|
||||
"name": "%s",
|
||||
"IMAP": {
|
||||
"host": "localhost",
|
||||
"port": 993,
|
||||
"type": 1,
|
||||
"timeout": 300,
|
||||
"shortLogin": false,
|
||||
"sasl": [
|
||||
"SCRAM-SHA3-512",
|
||||
"SCRAM-SHA-512",
|
||||
"SCRAM-SHA-256",
|
||||
"SCRAM-SHA-1",
|
||||
"PLAIN",
|
||||
"LOGIN"
|
||||
],
|
||||
"ssl": {
|
||||
"verify_peer": false,
|
||||
"verify_peer_name": false,
|
||||
"allow_self_signed": false,
|
||||
"SNI_enabled": true,
|
||||
"disable_compression": true,
|
||||
"security_level": 1
|
||||
},
|
||||
"use_expunge_all_on_delete": false,
|
||||
"fast_simple_search": true,
|
||||
"force_select": false,
|
||||
"message_all_headers": false,
|
||||
"message_list_limit": 10000,
|
||||
"search_filter": "",
|
||||
"disabled_capabilities": []
|
||||
},
|
||||
"SMTP": {
|
||||
"host": "localhost",
|
||||
"port": 587,
|
||||
"type": 2,
|
||||
"timeout": 60,
|
||||
"shortLogin": false,
|
||||
"sasl": [
|
||||
"SCRAM-SHA3-512",
|
||||
"SCRAM-SHA-512",
|
||||
"SCRAM-SHA-256",
|
||||
"SCRAM-SHA-1",
|
||||
"PLAIN",
|
||||
"LOGIN"
|
||||
],
|
||||
"ssl": {
|
||||
"verify_peer": false,
|
||||
"verify_peer_name": false,
|
||||
"allow_self_signed": false,
|
||||
"SNI_enabled": true,
|
||||
"disable_compression": true,
|
||||
"security_level": 1
|
||||
},
|
||||
"useAuth": true,
|
||||
"setSender": false,
|
||||
"usePhpMail": false,
|
||||
"authPlainLine": false
|
||||
},
|
||||
"Sieve": {
|
||||
"host": "",
|
||||
"port": 4190,
|
||||
"type": 0,
|
||||
"timeout": 10,
|
||||
"shortLogin": false,
|
||||
"sasl": [
|
||||
"SCRAM-SHA3-512",
|
||||
"SCRAM-SHA-512",
|
||||
"SCRAM-SHA-256",
|
||||
"SCRAM-SHA-1",
|
||||
"PLAIN",
|
||||
"LOGIN"
|
||||
],
|
||||
"ssl": {
|
||||
"verify_peer": false,
|
||||
"verify_peer_name": false,
|
||||
"allow_self_signed": false,
|
||||
"SNI_enabled": true,
|
||||
"disable_compression": true,
|
||||
"security_level": 1
|
||||
},
|
||||
"enabled": false
|
||||
},
|
||||
"whiteList": ""
|
||||
}
|
||||
""" % (domain)
|
||||
|
||||
WriteToFile = open(finalPathJson, 'w')
|
||||
WriteToFile.write(contentJSON)
|
||||
WriteToFile.close()
|
||||
|
||||
command = 'chown -R lscpd:lscpd /usr/local/lscp/cyberpanel/rainloop/data/'
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
|
||||
122
plogical/test.py
122
plogical/test.py
@@ -1,67 +1,67 @@
|
||||
#
|
||||
# import imaplib
|
||||
# import getpass
|
||||
# from email import message_from_string
|
||||
#
|
||||
# # IMAP server settings
|
||||
# imap_server = 'mail.wpmautic.net'
|
||||
# imap_port = 993
|
||||
#
|
||||
# # User credentials
|
||||
# email_address = 'usman@wpmautic.net'
|
||||
# password = getpass.getpass("Enter your email password: ")
|
||||
#
|
||||
# # Connect to the IMAP server
|
||||
# mail = imaplib.IMAP4_SSL(imap_server, imap_port)
|
||||
#
|
||||
# # Log in to the mailbox
|
||||
# mail.login(email_address, password)
|
||||
#
|
||||
# # Select the INBOX
|
||||
# mail.select("inbox")
|
||||
#
|
||||
# # Search for all emails in the INBOX
|
||||
# result, data = mail.search(None, "ALL")
|
||||
# email_ids = data[0].split()
|
||||
#
|
||||
# # Fetch and print header information for each email
|
||||
# for email_id in email_ids:
|
||||
# result, message_data = mail.fetch(email_id, "(BODY[HEADER.FIELDS (FROM TO SUBJECT DATE)])")
|
||||
# raw_email = message_data[0][1].decode('utf-8')
|
||||
# msg = message_from_string(raw_email)
|
||||
# print(f"Email ID: {email_id}")
|
||||
# print(f"From: {msg['From']}")
|
||||
# print(f"To: {msg['To']}")
|
||||
# print(f"Subject: {msg['Subject']}")
|
||||
# print(f"Date: {msg['Date']}")
|
||||
# print("-" * 30)
|
||||
#
|
||||
# # Logout
|
||||
# mail.logout()
|
||||
|
||||
from cryptography import x509
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
import imaplib
|
||||
import getpass
|
||||
from email import message_from_string
|
||||
|
||||
def get_domains_covered(cert_path):
|
||||
with open(cert_path, 'rb') as cert_file:
|
||||
cert_data = cert_file.read()
|
||||
cert = x509.load_pem_x509_certificate(cert_data, default_backend())
|
||||
# IMAP server settings
|
||||
imap_server = 'mail.wpmautic.net'
|
||||
imap_port = 993
|
||||
|
||||
# Check for the Subject Alternative Name (SAN) extension
|
||||
san_extension = cert.extensions.get_extension_for_class(x509.SubjectAlternativeName)
|
||||
# User credentials
|
||||
email_address = 'usman@wpmautic.net'
|
||||
password = getpass.getpass("Enter your email password: ")
|
||||
|
||||
if san_extension:
|
||||
# Extract and print the domains from SAN
|
||||
san_domains = san_extension.value.get_values_for_type(x509.DNSName)
|
||||
return san_domains
|
||||
else:
|
||||
# If SAN is not present, return the Common Name as a fallback
|
||||
return [cert.subject.get_attributes_for_oid(x509.NameOID.COMMON_NAME)[0].value]
|
||||
# Connect to the IMAP server
|
||||
mail = imaplib.IMAP4_SSL(imap_server, imap_port)
|
||||
|
||||
# Example usage
|
||||
cert_path = '/etc/letsencrypt/live/cyberplanner.io/fullchain.pem'
|
||||
domains_covered = get_domains_covered(cert_path)
|
||||
# Log in to the mailbox
|
||||
mail.login(email_address, password)
|
||||
|
||||
print("Domains covered by the certificate:")
|
||||
for domain in domains_covered:
|
||||
print(domain)
|
||||
# Select the INBOX
|
||||
mail.select("inbox")
|
||||
|
||||
# Search for all emails in the INBOX
|
||||
result, data = mail.search(None, "ALL")
|
||||
email_ids = data[0].split()
|
||||
|
||||
# Fetch and print header information for each email
|
||||
for email_id in email_ids:
|
||||
result, message_data = mail.fetch(email_id, "(BODY[HEADER.FIELDS (FROM TO SUBJECT DATE)])")
|
||||
raw_email = message_data[0][1].decode('utf-8')
|
||||
msg = message_from_string(raw_email)
|
||||
print(f"Email ID: {email_id}")
|
||||
print(f"From: {msg['From']}")
|
||||
print(f"To: {msg['To']}")
|
||||
print(f"Subject: {msg['Subject']}")
|
||||
print(f"Date: {msg['Date']}")
|
||||
print("-" * 30)
|
||||
|
||||
# Logout
|
||||
mail.logout()
|
||||
|
||||
# from cryptography import x509
|
||||
# from cryptography.hazmat.backends import default_backend
|
||||
#
|
||||
# def get_domains_covered(cert_path):
|
||||
# with open(cert_path, 'rb') as cert_file:
|
||||
# cert_data = cert_file.read()
|
||||
# cert = x509.load_pem_x509_certificate(cert_data, default_backend())
|
||||
#
|
||||
# # Check for the Subject Alternative Name (SAN) extension
|
||||
# san_extension = cert.extensions.get_extension_for_class(x509.SubjectAlternativeName)
|
||||
#
|
||||
# if san_extension:
|
||||
# # Extract and print the domains from SAN
|
||||
# san_domains = san_extension.value.get_values_for_type(x509.DNSName)
|
||||
# return san_domains
|
||||
# else:
|
||||
# # If SAN is not present, return the Common Name as a fallback
|
||||
# return [cert.subject.get_attributes_for_oid(x509.NameOID.COMMON_NAME)[0].value]
|
||||
#
|
||||
# # Example usage
|
||||
# cert_path = '/etc/letsencrypt/live/cyberplanner.io/fullchain.pem'
|
||||
# domains_covered = get_domains_covered(cert_path)
|
||||
#
|
||||
# print("Domains covered by the certificate:")
|
||||
# for domain in domains_covered:
|
||||
# print(domain)
|
||||
|
||||
@@ -155,6 +155,50 @@ class virtualHostUtilities:
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Completed. [200]')
|
||||
else:
|
||||
|
||||
### create site if not there
|
||||
|
||||
try:
|
||||
website = Websites.objects.get(domain=Domain)
|
||||
except:
|
||||
DataToPass = {}
|
||||
|
||||
currentTemp = tempStatusPath
|
||||
|
||||
DataToPass['domainName'] = Domain
|
||||
DataToPass['adminEmail'] = admin.email
|
||||
DataToPass['phpSelection'] = "PHP 8.0"
|
||||
DataToPass['websiteOwner'] = "admin"
|
||||
DataToPass['package'] = "Default"
|
||||
DataToPass['ssl'] = 1
|
||||
DataToPass['dkimCheck'] = 1
|
||||
DataToPass['openBasedir'] = 0
|
||||
DataToPass['mailDomain'] = 1
|
||||
DataToPass['apacheBackend'] = 0
|
||||
UserID = admin.pk
|
||||
|
||||
from websiteFunctions.website import WebsiteManager
|
||||
ab = WebsiteManager()
|
||||
coreResult = ab.submitWebsiteCreation(admin.id, DataToPass)
|
||||
coreResult1 = json.loads((coreResult).content)
|
||||
logging.CyberCPLogFileWriter.writeToFile("Creating website result....%s" % coreResult1)
|
||||
reutrntempath = coreResult1['tempStatusPath']
|
||||
while (1):
|
||||
lastLine = open(reutrntempath, 'r').read()
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile("Info web creating lastline ....... %s" % lastLine)
|
||||
if lastLine.find('[200]') > -1:
|
||||
break
|
||||
elif lastLine.find('[404]') > -1:
|
||||
statusFile = open(currentTemp, 'w')
|
||||
statusFile.writelines('Failed to Create Website: error: %s. [404]' % lastLine)
|
||||
statusFile.close()
|
||||
return 0
|
||||
else:
|
||||
statusFile = open(currentTemp, 'w')
|
||||
statusFile.writelines('Creating Website....,20')
|
||||
statusFile.close()
|
||||
time.sleep(2)
|
||||
|
||||
### Case 2 where postfix hostname either does not exist or does not match with server hostname or
|
||||
### hostname does not exists at all
|
||||
|
||||
|
||||
Reference in New Issue
Block a user