email_defaults = {
	"GMail": {
		"email_server": "pop.gmail.com",
		"use_ssl": 1,
		"enable_outgoing": 1,
		"smtp_server": "smtp.gmail.com",
		"smtp_port": 587,
		"use_tls": 1
	},
	"Outlook.com": {
		"email_server": "pop3.live.com",
		"use_ssl": 1,
		"enable_outgoing": 1,
		"smtp_server": "smtp.live.com",
		"smtp_port": 587,
		"use_tls": 1
	},
	"Yahoo Mail": {
		"email_server": "pop.mail.yahoo.com",
		"use_ssl": 1,
		"enable_outgoing": 1,
		"smtp_server": "smtp.mail.yahoo.com",
		"smtp_port": 465,
		"use_tls": 1
	},
	"Yandex.Mail": {
		"email_server": "pop.yandex.com",
		"use_ssl": 1,
		"enable_outgoing": 1,
		"smtp_server": "smtp.yandex.com",
		"smtp_port": 465,
		"use_tls": 0
	},
};

email_defaults_imap = {
	"GMail": {
		"email_server": "imap.gmail.com"
	},
	"Outlook.com": {
		"email_server": "imap.live.com"
	},
	"Yahoo Mail": {
		"email_server": "imap.mail.yahoo.com"
	},
	"Yandex.Mail": {
		"email_server": "imap.yandex.com"
	},

};

frappe.ui.form.on("Email Account", {
	service: function(frm) {
		$.each(email_defaults[frm.doc.service], function(key, value) {
			frm.set_value(key, value);
		})
		if (frm.doc.use_imap) {
			$.each(email_defaults_imap[frm.doc.service], function(key, value) {
				frm.set_value(key, value);
			});
		}
	},
	use_imap: function(frm) {
		if (frm.doc.use_imap) {
			$.each(email_defaults_imap[frm.doc.service], function(key, value) {
				frm.set_value(key, value);
			});
		}
		else{
			$.each(email_defaults[frm.doc.service], function(key, value) {
				frm.set_value(key, value);
			});
		}
	},
	email_id: function(frm) {
		if(!frm.doc.email_account_name) {
			frm.set_value("email_account_name",
				(frm.doc.service ? frm.doc.service + " " : "")
				+ toTitle(frm.doc.email_id.split("@")[0].replace(/[._]/g, " ")));
		}
	},
	enable_incoming: function(frm) {
		frm.set_df_property("append_to", "reqd", frm.doc.enable_incoming);
	},
	notify_if_unreplied: function(frm) {
		frm.set_df_property("send_notification_to", "reqd", frm.doc.notify_if_unreplied);
	},
	onload: function(frm) {
		frm.set_df_property("append_to", "only_select", true);
		frm.set_query("append_to", "frappe.email.doctype.email_account.email_account.get_append_to");
	},
	refresh: function(frm) {
		frm.events.enable_incoming(frm);
		frm.events.notify_if_unreplied(frm);
	}
});

@@ -1241,24 +1241,83 @@
 %0A%09%09%09%7D);%0A%09%09%7D%0A
+%09%09frm.events.show_gmail_message_for_less_secure_apps(frm);%0A
 %09%7D,%0A%09use_ima
@@ -2341,14 +2341,442 @@
 (frm);%0A%09
-%7D
+%09frm.events.show_gmail_message_for_less_secure_apps(frm);%0A%09%7D,%0A%09show_gmail_message_for_less_secure_apps: function(frm) %7B%0A%09%09frm.dashboard.reset();%0A%09%09if(frm.doc.service===%22GMail%22) %7B%0A%09%09%09frm.dashboard.set_headline_alert('GMail will only work if you allows access for Less Secure %5C%0A%09%09%09%09Apps in GMail Settings. %3Ca target=%22_blank%22 %5C%0A%09%09%09%09href=%22https://support.google.com/accounts/answer/6010255?hl=en%22%3ERead this for details%3C/a%3E');%0A%09%09%7D%0A%09%7D,
 %0A%7D);%0A

add message to enable Less Secure Apps in Google