-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_email_final.py
More file actions
111 lines (96 loc) · 3.95 KB
/
Copy pathfix_email_final.py
File metadata and controls
111 lines (96 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env python3
"""
Final fix for Email Account configuration issue
This script creates a proper email account to fix the encode error
"""
import os
import sys
# Add the bench path
sys.path.append('/home/frappe/frappe-bench/apps/frappe')
import frappe
def fix_email_account():
"""
Fix the email account configuration to prevent the encode error
"""
try:
# Initialize Frappe
frappe.init(site="crm.localhost")
frappe.connect()
print("🔧 Fixing email account configuration...")
# Check if email account already exists
existing_account = frappe.db.exists("Email Account", {"email_id": "information@variphi.com"})
if existing_account:
print(f"✅ Email account already exists: {existing_account}")
# Update the existing account
email_account = frappe.get_doc("Email Account", existing_account)
else:
print("📧 Creating new email account...")
# Create new email account
email_account = frappe.get_doc({
"doctype": "Email Account",
"email_account_name": "Variphi CRM",
"name": "Variphi CRM",
"email_id": "information@variphi.com",
"service": "",
"enable_incoming": 0,
"enable_outgoing": 1,
"default_incoming": 0,
"default_outgoing": 1,
"email_sync_option": "ALL",
"initial_sync_count": 100,
"create_contact": 1,
"track_email_status": 1,
"use_tls": 0,
"use_imap": 0,
"smtp_port": 465,
"smtp_server": "smtpout.secureserver.net",
"login": "information@variphi.com",
"password": "Nextneural@2402",
"use_ssl_for_outgoing": 1,
"always_use_account_email_id_as_sender": 1,
"no_smtp_authentication": 0,
"append_to": "CRM Lead",
"domain": "variphi.com",
"signature": "",
"enable_auto_reply": 0,
"auto_email_id": "information@variphi.com",
"awaiting_password": 0,
"ascii_encode_password": 0,
"login_id_is_different": 0,
"login_id": "information@variphi.com",
"validate_ssl_certificate": 0,
"use_starttls": 0,
"email_server": None,
"incoming_port": 0,
})
email_account.insert()
print("✅ Email account created successfully")
# Ensure the name field is properly set
if not email_account.name or email_account.name == "None":
email_account.name = "Variphi CRM"
email_account.save()
print("✅ Fixed name field")
# Set as default outgoing email account
frappe.db.set_value("Email Account", email_account.name, "default_outgoing", 1)
# Clear cache to ensure changes take effect
frappe.clear_cache()
print("✅ Email account configuration fixed successfully")
# Verify the fix
email_accounts = frappe.get_all("Email Account", filters={"default_outgoing": 1})
print(f"📧 Default outgoing email accounts: {len(email_accounts)}")
for acc in email_accounts:
acc_doc = frappe.get_doc("Email Account", acc.name)
print(f" - {acc_doc.name}: {acc_doc.email_id}")
return True
except Exception as e:
print(f"❌ Error fixing email account: {str(e)}")
return False
finally:
frappe.destroy()
if __name__ == "__main__":
print("Applying final email account fix...")
success = fix_email_account()
if success:
print("✅ Email account fix applied successfully")
else:
print("❌ Email account fix failed")