[mailbox] removed separate email settings for jobs, sales, support
diff --git a/erpnext/config/hr.py b/erpnext/config/hr.py
index 575de69..22f17e7 100644
--- a/erpnext/config/hr.py
+++ b/erpnext/config/hr.py
@@ -155,7 +155,7 @@
 				},
 				{
 					"type": "doctype",
-					"name": "Jobs Email Settings",
+					"name": "Email Account",
 					"description": _("Setup incoming server for jobs email id. (e.g. jobs@example.com)")
 				},
 			]
diff --git a/erpnext/config/selling.py b/erpnext/config/selling.py
index 1e5acad..e4d17bb 100644
--- a/erpnext/config/selling.py
+++ b/erpnext/config/selling.py
@@ -158,7 +158,7 @@
 				},
 				{
 					"type": "doctype",
-					"name": "Sales Email Settings",
+					"name": "Email Account",
 					"description": _("Setup incoming server for sales email id. (e.g. sales@example.com)")
 				},
 				{
diff --git a/erpnext/config/setup.py b/erpnext/config/setup.py
index 82fed9d..f3c0cec 100644
--- a/erpnext/config/setup.py
+++ b/erpnext/config/setup.py
@@ -75,21 +75,6 @@
 				},
 				{
 					"type": "doctype",
-					"name": "Support Email Settings",
-					"description": _("Setup incoming server for support email id. (e.g. support@example.com)")
-				},
-				{
-					"type": "doctype",
-					"name": "Sales Email Settings",
-					"description": _("Setup incoming server for sales email id. (e.g. sales@example.com)")
-				},
-				{
-					"type": "doctype",
-					"name": "Jobs Email Settings",
-					"description": _("Setup incoming server for jobs email id. (e.g. jobs@example.com)")
-				},
-				{
-					"type": "doctype",
 					"name": "SMS Settings",
 					"description": _("Setup SMS gateway settings")
 				},
diff --git a/erpnext/config/support.py b/erpnext/config/support.py
index 97807a3..7e243b2 100644
--- a/erpnext/config/support.py
+++ b/erpnext/config/support.py
@@ -49,7 +49,7 @@
 			"items": [
 				{
 					"type": "doctype",
-					"name": "Support Email Settings",
+					"name": "Email Account",
 					"description": _("Setup incoming server for support email id. (e.g. support@example.com)")
 				},
 			]
diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py
index 0f3dc48..9e237e1 100644
--- a/erpnext/controllers/selling_controller.py
+++ b/erpnext/controllers/selling_controller.py
@@ -33,13 +33,6 @@
 		self.validate_max_discount()
 		check_active_sales_items(self)
 
-	def get_sender(self, comm):
-		sender = None
-		if cint(frappe.db.get_value('Sales Email Settings', None, 'extract_emails')):
-			sender = frappe.db.get_value('Sales Email Settings', None, 'email_id')
-
-		return sender or comm.sender or frappe.session.user
-
 	def set_missing_values(self, for_validate=False):
 		super(SellingController, self).set_missing_values(for_validate)
 
diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py
index 1188be5..20b5057 100644
--- a/erpnext/controllers/status_updater.py
+++ b/erpnext/controllers/status_updater.py
@@ -8,28 +8,16 @@
 from frappe.model.document import Document
 
 status_map = {
-	"Contact": [
-		["Replied", "communication_sent"],
-		["Open", "communication_received"]
-	],
-	"Job Applicant": [
-		["Replied", "communication_sent"],
-		["Open", "communication_received"]
-	],
 	"Lead": [
-		["Replied", "communication_sent"],
 		["Converted", "has_customer"],
 		["Opportunity", "has_opportunity"],
-		["Open", "communication_received"],
 	],
 	"Opportunity": [
 		["Draft", None],
 		["Submitted", "eval:self.docstatus==1"],
 		["Lost", "eval:self.status=='Lost'"],
 		["Quotation", "has_quotation"],
-		["Replied", "communication_sent"],
 		["Cancelled", "eval:self.docstatus==2"],
-		["Open", "communication_received"],
 	],
 	"Quotation": [
 		["Draft", None],
@@ -46,10 +34,6 @@
 		["Stopped", "eval:self.status=='Stopped'"],
 		["Cancelled", "eval:self.docstatus==2"],
 	],
-	"Support Ticket": [
-		["Replied", "communication_sent"],
-		["Open", "communication_received"]
-	],
 }
 
 class StatusUpdater(Document):
@@ -90,25 +74,6 @@
 			if update:
 				frappe.db.set_value(self.doctype, self.name, "status", self.status)
 
-	def on_communication(self):
-		if not self.get("communications"): return
-		self.communication_set = True
-		self.get("communications").sort(key=lambda d: d.creation)
-		self.set_status(update=True)
-		del self.communication_set
-
-	def communication_received(self):
-		if getattr(self, "communication_set", False):
-			last_comm = self.get("communications")
-			if last_comm:
-				return last_comm[-1].sent_or_received == "Received"
-
-	def communication_sent(self):
-		if getattr(self, "communication_set", False):
-			last_comm = self.get("communications")
-			if last_comm:
-				return last_comm[-1].sent_or_received == "Sent"
-
 	def validate_qty(self):
 		"""
 			Validates qty at row level
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 0230126..65eee1f 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -38,11 +38,6 @@
 }
 
 scheduler_events = {
-	"all": [
-		"erpnext.support.doctype.support_ticket.get_support_mails.get_support_mails",
-		"erpnext.hr.doctype.job_applicant.get_job_applications.get_job_applications",
-		"erpnext.selling.doctype.lead.get_leads.get_leads"
-	],
 	"daily": [
 		"erpnext.controllers.recurring_document.create_recurring_documents",
 		"erpnext.stock.utils.reorder_item",
@@ -57,3 +52,6 @@
 	]
 }
 
+default_mail_footer = """<div style="padding: 7px; text-align: right; color: #888"><small>
+	<a style="color: #888" href="https://erpnext.com">Sent via ERPNext</a></div>"""
+
diff --git a/erpnext/hr/doctype/job_applicant/get_job_applications.py b/erpnext/hr/doctype/job_applicant/get_job_applications.py
deleted file mode 100644
index 2f08592..0000000
--- a/erpnext/hr/doctype/job_applicant/get_job_applications.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-from frappe.utils import cstr, cint
-from frappe.email.receive import POP3Server
-from frappe.core.doctype.communication.communication import _make
-
-class JobsMailbox(POP3Server):	
-	def setup(self, args=None):
-		self.settings = args or frappe.get_doc("Jobs Email Settings", "Jobs Email Settings")
-		
-	def process_message(self, mail):
-		if mail.from_email == self.settings.email_id:
-			return
-			
-		name = frappe.db.get_value("Job Applicant", {"email_id": mail.from_email}, 
-			"name")
-		if name:
-			applicant = frappe.get_doc("Job Applicant", name)
-			if applicant.status!="Rejected":
-				applicant.status = "Open"
-			applicant.ignore_permissions = True
-			applicant.save()
-		else:
-			name = (mail.from_real_name and (mail.from_real_name + " - ") or "") \
-				+ mail.from_email
-			applicant = frappe.get_doc({
-				"creation": mail.date,
-				"doctype":"Job Applicant",
-				"applicant_name": name,
-				"email_id": mail.from_email,
-				"status": "Open"
-			})
-			applicant.ignore_permissions = True
-			applicant.ignore_mandatory = True
-			applicant.insert()
-		
-		mail.save_attachments_in_doc(applicant)
-				
-		_make(content=mail.content, sender=mail.from_email, subject=mail.subject or "No Subject",
-			doctype="Job Applicant", name=applicant.name, sent_or_received="Received")
-
-def get_job_applications():
-	if cint(frappe.db.get_value('Jobs Email Settings', None, 'extract_emails')):
-		JobsMailbox()
\ No newline at end of file
diff --git a/erpnext/hr/doctype/job_applicant/job_applicant.py b/erpnext/hr/doctype/job_applicant/job_applicant.py
index 1f09c26..ddbf97f 100644
--- a/erpnext/hr/doctype/job_applicant/job_applicant.py
+++ b/erpnext/hr/doctype/job_applicant/job_applicant.py
@@ -5,13 +5,9 @@
 
 from __future__ import unicode_literals
 import frappe
-from erpnext.utilities.transaction_base import TransactionBase
+from frappe.model.document import Document
 from frappe.utils import extract_email_id
 
-class JobApplicant(TransactionBase):
-
-	def get_sender(self, comm):
-		return frappe.db.get_value('Jobs Email Settings',None,'email_id') or comm.sender or frappe.session.user
-
+class JobApplicant(Document):
 	def validate(self):
 		self.set_status()
diff --git a/erpnext/patches/v4_0/reset_permissions_for_masters.py b/erpnext/patches/v4_0/reset_permissions_for_masters.py
index d031bd0..30aa47a 100644
--- a/erpnext/patches/v4_0/reset_permissions_for_masters.py
+++ b/erpnext/patches/v4_0/reset_permissions_for_masters.py
@@ -10,9 +10,9 @@
 		"Comment", "Communication", "Company", "Contact Us Settings",
 		"Country", "Currency", "Currency Exchange", "Deduction Type", "Department",
 		"Designation", "Earning Type", "Event", "Feed", "File Data", "Fiscal Year",
-		"HR Settings", "Industry Type", "Jobs Email Settings", "Leave Type", "Letter Head",
+		"HR Settings", "Industry Type", "Leave Type", "Letter Head",
 		"Mode of Payment", "Module Def", "Naming Series", "POS Setting", "Print Heading",
-		"Report", "Role", "Sales Email Settings", "Selling Settings", "Stock Settings", "Supplier Type", "UOM"):
+		"Report", "Role", "Selling Settings", "Stock Settings", "Supplier Type", "UOM"):
 		try:
 			frappe.reset_perms(doctype)
 		except:
diff --git a/erpnext/patches/v4_0/split_email_settings.py b/erpnext/patches/v4_0/split_email_settings.py
index dd36eef..c04e1d5 100644
--- a/erpnext/patches/v4_0/split_email_settings.py
+++ b/erpnext/patches/v4_0/split_email_settings.py
@@ -5,6 +5,16 @@
 import frappe
 
 def execute():
+	print "WARNING!!!! Email Settings not migrated. Please setup your email again."
+
+	# this will happen if you are migrating very old accounts
+	# comment out this line below and remember to create new Email Accounts
+	# for incoming and outgoing mails
+	raise Exception
+
+	return
+
+
 	frappe.reload_doc("core", "doctype", "outgoing_email_settings")
 	frappe.reload_doc("support", "doctype", "support_email_settings")
 
@@ -12,7 +22,6 @@
 	map_outgoing_email_settings(email_settings)
 	map_support_email_settings(email_settings)
 
-	frappe.delete_doc("DocType", "Email Settings")
 
 def map_outgoing_email_settings(email_settings):
 	outgoing_email_settings = frappe.get_doc("Outgoing Email Settings")
diff --git a/erpnext/patches/v4_1/set_outgoing_email_footer.py b/erpnext/patches/v4_1/set_outgoing_email_footer.py
index d38f2c2..73d8d60 100644
--- a/erpnext/patches/v4_1/set_outgoing_email_footer.py
+++ b/erpnext/patches/v4_1/set_outgoing_email_footer.py
@@ -6,6 +6,7 @@
 from erpnext.setup.install import default_mail_footer
 
 def execute():
+	return
 	mail_footer = frappe.db.get_default('mail_footer') or ''
 	mail_footer += default_mail_footer
 	frappe.db.set_value("Outgoing Email Settings", "Outgoing Email Settings", "footer", mail_footer)
diff --git a/erpnext/setup/doctype/jobs_email_settings/__init__.py b/erpnext/patches/v4_4/__init__.py
similarity index 100%
rename from erpnext/setup/doctype/jobs_email_settings/__init__.py
rename to erpnext/patches/v4_4/__init__.py
diff --git a/erpnext/patches/v4_4/make_email_accounts.py b/erpnext/patches/v4_4/make_email_accounts.py
new file mode 100644
index 0000000..9e8538d
--- /dev/null
+++ b/erpnext/patches/v4_4/make_email_accounts.py
@@ -0,0 +1,73 @@
+import frappe
+
+def execute():
+	frappe.reload_doc("email", "doctype", "email_account")
+
+	# outgoing
+	outgoing = frappe.get_doc("Outgoing Email Settings")
+	account = frappe.new_doc("Email Account")
+	mapping = {
+		"email_id": "mail_login",
+		"password": "mail_password",
+		"footer": "footer",
+		"smtp_server": "mail_server",
+		"smtp_port": "mail_port",
+		"use_tls": "use_ssl"
+	}
+
+	for target_fieldname, source_fieldname in mapping.iteritems():
+		account.set(target_fieldname, outgoing.get(source_fieldname))
+
+	account.enable_outgoing = 1
+	account.enable_incoming = 0
+	account.is_global = 1
+
+	account.insert()
+
+	# support
+	support = frappe.get_doc("Support Email Settings")
+	account = frappe.new_doc("Email Account")
+	mapping = {
+		"enable_incoming": "sync_support_mails",
+		"email_id": "mail_login",
+		"password": "mail_password",
+		"pop3_server": "mail_server",
+		"use_ssl": "use_ssl",
+		"signature": "support_signature",
+		"enable_auto_reply": "send_autoreply",
+		"auto_reply_message": "support_autoreply"
+	}
+
+	for target_fieldname, source_fieldname in mapping.iteritems():
+		account.set(target_fieldname, support.get(source_fieldname))
+
+	account.enable_outgoing = 0
+	account.is_global = 1
+
+	account.insert()
+
+	# sales, jobs
+	for doctype in ("Sales Email Settings", "Jobs Email Settings"):
+		source = frappe.get_doc(doctype)
+		account = frappe.new_doc("Email Account")
+		mapping = {
+			"enable_incoming": "extract_emails",
+			"email_id": "username",
+			"password": "password",
+			"pop3_server": "host",
+			"use_ssl": "use_ssl",
+		}
+
+		for target_fieldname, source_fieldname in mapping.iteritems():
+			account.set(target_fieldname, source.get(source_fieldname))
+
+		account.enable_outgoing = 0
+		account.is_global = 1
+		account.append_to = "Lead" if doctype=="Sales Email Settings" else "Job Applicant"
+
+		account.insert()
+
+	for doctype in ("Outgoing Email Settings", "Support Email Settings",
+		"Sales Email Settings", "Jobs Email Settings"):
+		frappe.delete_doc("DocType", doctype)
+
diff --git a/erpnext/selling/doctype/lead/get_leads.py b/erpnext/selling/doctype/lead/get_leads.py
deleted file mode 100644
index f7b30a7..0000000
--- a/erpnext/selling/doctype/lead/get_leads.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-from frappe.utils import cstr, cint
-from frappe.email.receive import POP3Server
-from frappe.core.doctype.communication.communication import _make
-
-def add_sales_communication(subject, content, sender, real_name, mail=None, 
-	status="Open", date=None):
-	lead_name = frappe.db.get_value("Lead", {"email_id": sender})
-	contact_name = frappe.db.get_value("Contact", {"email_id": sender})
-
-	if not (lead_name or contact_name):
-		# none, create a new Lead
-		lead = frappe.get_doc({
-			"doctype":"Lead",
-			"lead_name": real_name or sender,
-			"email_id": sender,
-			"status": status,
-			"source": "Email"
-		})
-		lead.ignore_permissions = True
-		lead.ignore_mandatory = True
-		lead.insert()
-		lead_name = lead.name
-
-	parent_doctype = "Contact" if contact_name else "Lead"
-	parent_name = contact_name or lead_name
-
-	message = _make(content=content, sender=sender, subject=subject,
-		doctype = parent_doctype, name = parent_name, date=date, sent_or_received="Received")
-	
-	if mail:
-		# save attachments to parent if from mail
-		doc = frappe.get_doc(parent_doctype, parent_name)
-		mail.save_attachments_in_doc(doc)
-
-class SalesMailbox(POP3Server):	
-	def setup(self, args=None):
-		self.settings = args or frappe.get_doc("Sales Email Settings", "Sales Email Settings")
-		
-	def process_message(self, mail):
-		if mail.from_email == self.settings.email_id:
-			return
-		
-		add_sales_communication(mail.subject, mail.content, mail.from_email, 
-			mail.from_real_name, mail=mail, date=mail.date)
-
-def get_leads():
-	if cint(frappe.db.get_value('Sales Email Settings', None, 'extract_emails')):
-		SalesMailbox()
\ No newline at end of file
diff --git a/erpnext/setup/doctype/jobs_email_settings/README.md b/erpnext/setup/doctype/jobs_email_settings/README.md
deleted file mode 100644
index 8314c55..0000000
--- a/erpnext/setup/doctype/jobs_email_settings/README.md
+++ /dev/null
@@ -1 +0,0 @@
-Settings to extract job applications via email (POP).
\ No newline at end of file
diff --git a/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.js b/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.js
deleted file mode 100644
index cda8fd6..0000000
--- a/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.js
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
-// License: GNU General Public License v3. See license.txt
-
-// For license information, please see license.txt
-
-cur_frm.cscript = {
-	refresh: function(doc) {
-		cur_frm.set_intro("");
-		if(doc.extract_emails) {
-			cur_frm.set_intro(__("Active: Will extract emails from ") + doc.email_id);
-		} else {
-			cur_frm.set_intro(__("Not Active"));
-		}
-	}
-}
\ No newline at end of file
diff --git a/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.json b/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.json
deleted file mode 100644
index e6fec9d..0000000
--- a/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.json
+++ /dev/null
@@ -1,73 +0,0 @@
-{
- "creation": "2013-01-15 16:50:01.000000", 
- "description": "Email settings for jobs email id \"jobs@example.com\"", 
- "docstatus": 0, 
- "doctype": "DocType", 
- "fields": [
-  {
-   "description": "Settings to extract Job Applicants from a mailbox e.g. \"jobs@example.com\"", 
-   "fieldname": "pop3_mail_settings", 
-   "fieldtype": "Section Break", 
-   "label": "POP3 Mail Settings", 
-   "permlevel": 0
-  }, 
-  {
-   "description": "Check to activate", 
-   "fieldname": "extract_emails", 
-   "fieldtype": "Check", 
-   "label": "Extract Emails", 
-   "permlevel": 0
-  }, 
-  {
-   "description": "Email Id where a job applicant will email e.g. \"jobs@example.com\"", 
-   "fieldname": "email_id", 
-   "fieldtype": "Data", 
-   "label": "Email Id", 
-   "permlevel": 0
-  }, 
-  {
-   "description": "POP3 server e.g. (pop.gmail.com)", 
-   "fieldname": "host", 
-   "fieldtype": "Data", 
-   "label": "Host", 
-   "permlevel": 0
-  }, 
-  {
-   "fieldname": "use_ssl", 
-   "fieldtype": "Check", 
-   "label": "Use SSL", 
-   "permlevel": 0
-  }, 
-  {
-   "fieldname": "username", 
-   "fieldtype": "Data", 
-   "label": "Username", 
-   "permlevel": 0
-  }, 
-  {
-   "fieldname": "password", 
-   "fieldtype": "Password", 
-   "label": "Password", 
-   "permlevel": 0
-  }
- ], 
- "icon": "icon-cog", 
- "idx": 1, 
- "issingle": 1, 
- "modified": "2013-12-20 19:23:16.000000", 
- "modified_by": "Administrator", 
- "module": "Setup", 
- "name": "Jobs Email Settings", 
- "owner": "Administrator", 
- "permissions": [
-  {
-   "create": 1, 
-   "email": 1, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "role": "System Manager", 
-   "write": 1
-  }
- ]
-}
\ No newline at end of file
diff --git a/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.py b/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.py
deleted file mode 100644
index 5d8bab8..0000000
--- a/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-# For license information, please see license.txt
-
-from __future__ import unicode_literals
-import frappe
-from frappe import _
-from frappe.utils import cint
-
-from frappe.model.document import Document
-
-class JobsEmailSettings(Document):
-
-	def validate(self):
-		if cint(self.extract_emails) and not (self.email_id and self.host and \
-			self.username and self.password):
-
-			frappe.throw(_("""Host, Email and Password required if emails are to be pulled"""))
diff --git a/erpnext/setup/doctype/sales_email_settings/README.md b/erpnext/setup/doctype/sales_email_settings/README.md
deleted file mode 100644
index 8d7d48f..0000000
--- a/erpnext/setup/doctype/sales_email_settings/README.md
+++ /dev/null
@@ -1 +0,0 @@
-Settings for creating new Communication, Leads from sales inbox like "sales@example.com" via POP3.
\ No newline at end of file
diff --git a/erpnext/setup/doctype/sales_email_settings/__init__.py b/erpnext/setup/doctype/sales_email_settings/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/erpnext/setup/doctype/sales_email_settings/__init__.py
+++ /dev/null
diff --git a/erpnext/setup/doctype/sales_email_settings/sales_email_settings.js b/erpnext/setup/doctype/sales_email_settings/sales_email_settings.js
deleted file mode 100644
index cda8fd6..0000000
--- a/erpnext/setup/doctype/sales_email_settings/sales_email_settings.js
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
-// License: GNU General Public License v3. See license.txt
-
-// For license information, please see license.txt
-
-cur_frm.cscript = {
-	refresh: function(doc) {
-		cur_frm.set_intro("");
-		if(doc.extract_emails) {
-			cur_frm.set_intro(__("Active: Will extract emails from ") + doc.email_id);
-		} else {
-			cur_frm.set_intro(__("Not Active"));
-		}
-	}
-}
\ No newline at end of file
diff --git a/erpnext/setup/doctype/sales_email_settings/sales_email_settings.json b/erpnext/setup/doctype/sales_email_settings/sales_email_settings.json
deleted file mode 100644
index c19f2e2..0000000
--- a/erpnext/setup/doctype/sales_email_settings/sales_email_settings.json
+++ /dev/null
@@ -1,73 +0,0 @@
-{
- "creation": "2013-01-16 10:25:26.000000", 
- "description": "Email settings to extract Leads from sales email id e.g. \"sales@example.com\"", 
- "docstatus": 0, 
- "doctype": "DocType", 
- "fields": [
-  {
-   "description": "Email settings to extract Leads from sales email id e.g. \"sales@example.com\"", 
-   "fieldname": "pop3_mail_settings", 
-   "fieldtype": "Section Break", 
-   "label": "POP3 Mail Settings", 
-   "permlevel": 0
-  }, 
-  {
-   "description": "Check to activate", 
-   "fieldname": "extract_emails", 
-   "fieldtype": "Check", 
-   "label": "Extract Emails", 
-   "permlevel": 0
-  }, 
-  {
-   "description": "Email Id where a job applicant will email e.g. \"jobs@example.com\"", 
-   "fieldname": "email_id", 
-   "fieldtype": "Data", 
-   "label": "Email Id", 
-   "permlevel": 0
-  }, 
-  {
-   "description": "POP3 server e.g. (pop.gmail.com)", 
-   "fieldname": "host", 
-   "fieldtype": "Data", 
-   "label": "Host", 
-   "permlevel": 0
-  }, 
-  {
-   "fieldname": "use_ssl", 
-   "fieldtype": "Check", 
-   "label": "Use SSL", 
-   "permlevel": 0
-  }, 
-  {
-   "fieldname": "username", 
-   "fieldtype": "Data", 
-   "label": "Username", 
-   "permlevel": 0
-  }, 
-  {
-   "fieldname": "password", 
-   "fieldtype": "Password", 
-   "label": "Password", 
-   "permlevel": 0
-  }
- ], 
- "icon": "icon-cog", 
- "idx": 1, 
- "issingle": 1, 
- "modified": "2013-12-20 19:21:38.000000", 
- "modified_by": "Administrator", 
- "module": "Setup", 
- "name": "Sales Email Settings", 
- "owner": "Administrator", 
- "permissions": [
-  {
-   "create": 1, 
-   "email": 1, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "role": "System Manager", 
-   "write": 1
-  }
- ]
-}
\ No newline at end of file
diff --git a/erpnext/setup/doctype/sales_email_settings/sales_email_settings.py b/erpnext/setup/doctype/sales_email_settings/sales_email_settings.py
deleted file mode 100644
index 88dc411..0000000
--- a/erpnext/setup/doctype/sales_email_settings/sales_email_settings.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-# For license information, please see license.txt
-
-from __future__ import unicode_literals
-import frappe
-from frappe import _
-from frappe.utils import cint
-
-from frappe.model.document import Document
-
-class SalesEmailSettings(Document):
-		
-	def validate(self):
-		if cint(self.extract_emails) and not (self.email_id and self.host and \
-			self.username and self.password):
-			
-			frappe.msgprint(_("""Host, Email and Password required if emails are to be pulled"""),
-				raise_exception=True)
\ No newline at end of file
diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py
index 93f4ad5..dce101e 100644
--- a/erpnext/setup/install.py
+++ b/erpnext/setup/install.py
@@ -52,6 +52,3 @@
 				pass
 
 	frappe.db.set_default("date_format", "dd-mm-yyyy")
-
-	frappe.db.set_value("Outgoing Email Settings", "Outgoing Email Settings", "footer",
-		default_mail_footer)
diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py
index 14c409b..bc49090 100644
--- a/erpnext/stock/doctype/serial_no/serial_no.py
+++ b/erpnext/stock/doctype/serial_no/serial_no.py
@@ -192,9 +192,6 @@
 			self.set_sales_details(last_sle.get("delivery_sle"))
 			self.set_maintenance_status()
 
-	def on_communication(self):
-		return
-
 def process_serial_no(sle):
 	item_det = get_item_details(sle.item_code)
 	validate_serial_no(sle, item_det)
diff --git a/erpnext/support/doctype/support_email_settings/__init__.py b/erpnext/support/doctype/support_email_settings/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/erpnext/support/doctype/support_email_settings/__init__.py
+++ /dev/null
diff --git a/erpnext/support/doctype/support_email_settings/support_email_settings.json b/erpnext/support/doctype/support_email_settings/support_email_settings.json
deleted file mode 100644
index dd45049..0000000
--- a/erpnext/support/doctype/support_email_settings/support_email_settings.json
+++ /dev/null
@@ -1,92 +0,0 @@
-{
- "allow_copy": 1, 
- "creation": "2014-03-03 19:48:46.000000", 
- "description": "Email Settings for Outgoing and Incoming Emails.", 
- "docstatus": 0, 
- "doctype": "DocType", 
- "fields": [
-  {
-   "description": "Check this to pull emails from your mailbox", 
-   "fieldname": "sync_support_mails", 
-   "fieldtype": "Check", 
-   "label": "Sync Support Mails", 
-   "permlevel": 0
-  }, 
-  {
-   "description": "Your support email id - must be a valid email - this is where your emails will come!", 
-   "fieldname": "support_email", 
-   "fieldtype": "Data", 
-   "label": "Support Email", 
-   "permlevel": 0
-  }, 
-  {
-   "description": "POP3 mail server (e.g. pop.gmail.com)", 
-   "fieldname": "mail_server", 
-   "fieldtype": "Data", 
-   "label": "POP3 Mail Server", 
-   "permlevel": 0
-  }, 
-  {
-   "fieldname": "use_ssl", 
-   "fieldtype": "Check", 
-   "label": "Use SSL", 
-   "permlevel": 0
-  }, 
-  {
-   "fieldname": "mail_login", 
-   "fieldtype": "Data", 
-   "label": "User Name", 
-   "permlevel": 0
-  }, 
-  {
-   "fieldname": "mail_password", 
-   "fieldtype": "Password", 
-   "label": "Support Password", 
-   "permlevel": 0
-  }, 
-  {
-   "fieldname": "cb1", 
-   "fieldtype": "Column Break", 
-   "permlevel": 0
-  }, 
-  {
-   "description": "Signature to be appended at the end of every email", 
-   "fieldname": "support_signature", 
-   "fieldtype": "Text", 
-   "label": "Signature", 
-   "permlevel": 0
-  }, 
-  {
-   "default": "1", 
-   "fieldname": "send_autoreply", 
-   "fieldtype": "Check", 
-   "label": "Send Autoreply", 
-   "permlevel": 0
-  }, 
-  {
-   "description": "Autoreply when a new mail is received", 
-   "fieldname": "support_autoreply", 
-   "fieldtype": "Text", 
-   "label": "Custom Autoreply Message", 
-   "permlevel": 0
-  }
- ], 
- "icon": "icon-cog", 
- "idx": 1, 
- "in_create": 1, 
- "issingle": 1, 
- "modified": "2014-03-03 20:20:34.000000", 
- "modified_by": "Administrator", 
- "module": "Support", 
- "name": "Support Email Settings", 
- "owner": "Administrator", 
- "permissions": [
-  {
-   "create": 1, 
-   "permlevel": 0, 
-   "read": 1, 
-   "role": "System Manager", 
-   "write": 1
-  }
- ]
-}
\ No newline at end of file
diff --git a/erpnext/support/doctype/support_email_settings/support_email_settings.py b/erpnext/support/doctype/support_email_settings/support_email_settings.py
deleted file mode 100644
index c7eb1b8..0000000
--- a/erpnext/support/doctype/support_email_settings/support_email_settings.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
-# MIT License. See license.txt
-
-# For license information, please see license.txt
-
-from __future__ import unicode_literals
-import frappe
-from frappe import _
-from frappe.utils import cint
-from frappe.model.document import Document
-from frappe.email.receive import POP3Server
-import _socket, poplib
-
-class SupportEmailSettings(Document):
-
-	def validate(self):
-		"""
-			Checks support ticket email settings
-		"""
-		if cint(self.sync_support_mails) and self.mail_server and not frappe.local.flags.in_patch:
-			inc_email = frappe._dict(self.as_dict())
-			# inc_email.encode()
-			inc_email.host = self.mail_server
-			inc_email.use_ssl = self.use_ssl
-			try:
-				err_msg = _('User Name or Support Password missing. Please enter and try again.')
-				if not (self.mail_login and self.mail_password):
-					raise AttributeError, err_msg
-				inc_email.username = self.mail_login
-				inc_email.password = self.mail_password
-			except AttributeError, e:
-				frappe.msgprint(err_msg)
-				raise
-
-			pop_mb = POP3Server(inc_email)
-
-			try:
-				pop_mb.connect()
-			except _socket.error, e:
-				# Invalid mail server -- due to refusing connection
-				frappe.msgprint(_('Invalid Mail Server. Please rectify and try again.'))
-				raise
-			except poplib.error_proto, e:
-				frappe.msgprint(_('Invalid User Name or Support Password. Please rectify and try again.'))
-				raise
diff --git a/erpnext/support/doctype/support_ticket/get_support_mails.py b/erpnext/support/doctype/support_ticket/get_support_mails.py
deleted file mode 100644
index 894d956..0000000
--- a/erpnext/support/doctype/support_ticket/get_support_mails.py
+++ /dev/null
@@ -1,87 +0,0 @@
-# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-from frappe.utils import cstr, cint, decode_dict, today
-from frappe.email import sendmail
-from frappe.email.receive import POP3Server
-from frappe.core.doctype.communication.communication import _make
-
-class SupportMailbox(POP3Server):
-	def setup(self, args=None):
-		self.email_settings = frappe.get_doc("Support Email Settings", "Support Email Settings")
-		self.settings = args or frappe._dict({
-			"use_ssl": self.email_settings.use_ssl,
-			"host": self.email_settings.mail_server,
-			"username": self.email_settings.mail_login,
-			"password": self.email_settings.mail_password
-		})
-
-	def process_message(self, mail):
-		if mail.from_email == self.email_settings.get('support_email'):
-			return
-		thread_id = mail.get_thread_id()
-		new_ticket = False
-
-		if not (thread_id and frappe.db.exists("Support Ticket", thread_id)):
-			new_ticket = True
-
-		ticket = add_support_communication(mail.subject, mail.content, mail.from_email,
-			docname=None if new_ticket else thread_id, mail=mail)
-
-		if new_ticket and cint(self.email_settings.send_autoreply) and \
-			"mailer-daemon" not in mail.from_email.lower():
-				self.send_auto_reply(ticket)
-
-	def send_auto_reply(self, d):
-		signature = self.email_settings.get('support_signature') or ''
-		response = self.email_settings.get('support_autoreply') or ("""
-A new Ticket has been raised for your query. If you have any additional information, please
-reply back to this mail.
-
-### We will get back to you as soon as possible
-
----
-
-Original Query:
-
-""" + d.description + "\n\n---\n\n" + cstr(signature))
-
-		sendmail(\
-			recipients = [cstr(d.raised_by)], \
-			sender = cstr(self.email_settings.get('support_email')), \
-			subject = '['+cstr(d.name)+'] ' + cstr(d.subject), \
-			msg = cstr(response))
-
-def get_support_mails():
-	if cint(frappe.db.get_value('Support Email Settings', None, 'sync_support_mails')):
-		SupportMailbox()
-
-def add_support_communication(subject, content, sender, docname=None, mail=None):
-	if docname:
-		ticket = frappe.get_doc("Support Ticket", docname)
-		ticket.status = 'Open'
-		ticket.ignore_permissions = True
-		ticket.save()
-	else:
-		ticket = frappe.get_doc(decode_dict({
-			"doctype":"Support Ticket",
-			"description": content,
-			"subject": subject,
-			"raised_by": sender,
-			"content_type": mail.content_type if mail else None,
-			"status": "Open",
-		}))
-		ticket.ignore_permissions = True
-		ticket.ignore_mandatory = True
-		ticket.insert()
-
-	_make(content=content, sender=sender, subject = subject,
-		doctype="Support Ticket", name=ticket.name,
-		date=mail.date if mail else today(), sent_or_received="Received")
-
-	if mail:
-		mail.save_attachments_in_doc(ticket)
-
-	return ticket
diff --git a/erpnext/support/doctype/support_ticket/support_ticket.py b/erpnext/support/doctype/support_ticket/support_ticket.py
index 1212218..226df0f 100644
--- a/erpnext/support/doctype/support_ticket/support_ticket.py
+++ b/erpnext/support/doctype/support_ticket/support_ticket.py
@@ -5,26 +5,13 @@
 import frappe
 from frappe import _
 
-from erpnext.utilities.transaction_base import TransactionBase
-from frappe.utils import now, extract_email_id
+from frappe.model.document import Document
+from frappe.utils import now
 
-class SupportTicket(TransactionBase):
+class SupportTicket(Document):
 	def get_feed(self):
 		return "{0}: {1}".format(_(self.status, self.subject))
 
-	def get_sender(self, comm):
-		return frappe.db.get_value('Support Email Settings',None,'support_email')
-
-	def get_subject(self, comm):
-		return '[' + self.name + '] ' + (comm.subject or 'No Subject Specified')
-
-	def get_content(self, comm):
-		signature = frappe.db.get_value('Support Email Settings',None,'support_signature')
-		content = comm.content
-		if signature:
-			content += '<p>' + signature + '</p>'
-		return content
-
 	def get_portal_page(self):
 		return "ticket"
 
diff --git a/erpnext/templates/utils.py b/erpnext/templates/utils.py
index d3c93eb..9892924 100644
--- a/erpnext/templates/utils.py
+++ b/erpnext/templates/utils.py
@@ -7,19 +7,14 @@
 @frappe.whitelist(allow_guest=True)
 def send_message(subject="Website Query", message="", sender="", status="Open"):
 	from frappe.templates.pages.contact import send_message as website_send_message
-	res = website_send_message(subject, message, sender)
 
-	if not res:
-		return
+	website_send_message(subject, message, sender)
 
-	if subject=="Support":
-		# create support ticket
-		from erpnext.support.doctype.support_ticket.get_support_mails import add_support_communication
-		add_support_communication(subject, message, sender, mail=None)
-	else:
-		# make lead / communication
-		from erpnext.selling.doctype.lead.get_leads import add_sales_communication
-		add_sales_communication(subject or "Website Query", message, sender, sender,
-			mail=None, status=status)
-
-	return res
+	comm = frappe.get_doc({
+		"doctype":"Communication",
+		"subject": subject,
+		"content": message,
+		"sender": sender,
+		"sent_or_received": "Received"
+	})
+	comm.insert(ignore_permissions=True)