コード例 #1
0
	def set_from(self):
		# gmail mailing-list compatibility
		# use X-Original-Sender if available, as gmail sometimes modifies the 'From'
		_from_email = self.decode_email(self.mail.get("X-Original-From") or self.mail["From"])
		_reply_to = self.decode_email(self.mail.get("Reply-To"))

		if _reply_to and not frappe.db.get_value('Email Account', {"email_id":_reply_to}, 'email_id'):
			self.from_email = extract_email_id(_reply_to)
		else:
			self.from_email = extract_email_id(_from_email)

		if self.from_email:
			self.from_email = self.from_email.lower()

		self.from_real_name = email.utils.parseaddr(_from_email)[0] if "@" in _from_email else _from_email
コード例 #2
0
ファイル: receive.py プロジェクト: ashishacharya/frappe
	def __init__(self, content):
		"""Parses headers, content, attachments from given raw message.

		:param content: Raw message."""
		import email, email.utils
		import datetime


		self.raw = content
		self.mail = email.message_from_string(self.raw)

		self.text_content = ''
		self.html_content = ''
		self.attachments = []
		self.cid_map = {}
		self.parse()
		self.set_content_and_type()
		self.set_subject()

		self.from_email = extract_email_id(self.mail["From"])
		self.from_real_name = email.utils.parseaddr(self.mail["From"])[0]

		if self.mail["Date"]:
			utc = email.utils.mktime_tz(email.utils.parsedate_tz(self.mail["Date"]))
			utc_dt = datetime.datetime.utcfromtimestamp(utc)
			self.date = convert_utc_to_user_timezone(utc_dt).strftime('%Y-%m-%d %H:%M:%S')
		else:
			self.date = now()
コード例 #3
0
ファイル: receive.py プロジェクト: AhmedHamedTN/frappe
	def __init__(self, content):
		"""Parses headers, content, attachments from given raw message.

		:param content: Raw message."""
		import email, email.utils
		import datetime


		self.raw = content
		self.mail = email.message_from_string(self.raw)

		self.text_content = ''
		self.html_content = ''
		self.attachments = []
		self.cid_map = {}
		self.parse()
		self.set_content_and_type()
		self.set_subject()

		# gmail mailing-list compatibility
		# use X-Original-Sender if available, as gmail sometimes modifies the 'From'
		_from_email = self.mail.get("X-Original-From") or self.mail["From"]

		self.from_email = extract_email_id(_from_email)
		self.from_real_name = email.utils.parseaddr(_from_email)[0]

		if self.mail["Date"]:
			utc = email.utils.mktime_tz(email.utils.parsedate_tz(self.mail["Date"]))
			utc_dt = datetime.datetime.utcfromtimestamp(utc)
			self.date = convert_utc_to_user_timezone(utc_dt).strftime('%Y-%m-%d %H:%M:%S')
		else:
			self.date = now()
コード例 #4
0
    def set_from(self):
        # gmail mailing-list compatibility
        # use X-Original-Sender if available, as gmail sometimes modifies the 'From'
        _from_email = self.decode_email(
            self.mail.get("X-Original-From") or self.mail["From"])
        _reply_to = self.decode_email(self.mail.get("Reply-To"))

        if _reply_to and not frappe.db.get_value(
                'Email Account', {"email_id": _reply_to}, 'email_id'):
            self.from_email = extract_email_id(_reply_to)
        else:
            self.from_email = extract_email_id(_from_email)

        if self.from_email:
            self.from_email = self.from_email.lower()

        self.from_real_name = parse_addr(
            _from_email)[0] if "@" in _from_email else _from_email
コード例 #5
0
    def set_from(self):
        # gmail mailing-list compatibility
        # use X-Original-Sender if available, as gmail sometimes modifies the 'From'
        _from_email = self.mail.get("X-Original-From") or self.mail["From"]
        _from_email, encoding = decode_header(_from_email)[0]

        if encoding:
            _from_email = _from_email.decode(encoding)
        else:
            _from_email = _from_email.decode('utf-8')

        self.from_email = extract_email_id(_from_email)
        self.from_real_name = email.utils.parseaddr(_from_email)[0]
コード例 #6
0
ファイル: receive.py プロジェクト: mhbu50/frappe
	def set_from(self):
		# gmail mailing-list compatibility
		# use X-Original-Sender if available, as gmail sometimes modifies the 'From'
		_from_email = self.mail.get("X-Original-From") or self.mail["From"]
		_from_email, encoding = decode_header(_from_email)[0]

		if encoding:
			_from_email = _from_email.decode(encoding)
		else:
			_from_email = _from_email.decode('utf-8')

		self.from_email = extract_email_id(_from_email)
		self.from_real_name = email.utils.parseaddr(_from_email)[0]
コード例 #7
0
ファイル: receive.py プロジェクト: RicardoJohann/frappe
	def __init__(self, content):
		"""Parses headers, content, attachments from given raw message.

		:param content: Raw message."""
		import email, email.utils,email.header
		import datetime


		self.raw = content
		self.mail = email.message_from_string(self.raw)

		self.text_content = ''
		self.html_content = ''
		self.attachments = []
		self.cid_map = {}
		self.parse()
		self.set_content_and_type()
		self.set_subject()
		self.message_id = self.mail.__getitem__('Message-ID')
		#self.unique_id = hashlib.md5((self.mail.get("X-Original-From") or self.mail["From"])+(self.mail.get("To") or self.mail.get("Envelope-to"))+(self.mail.get("Received") or self.mail["Date"] )).hexdigest()



		self.unique_id = get_unique_id(self.mail)

		# gmail mailing-list compatibility
		# use X-Original-Sender if available, as gmail sometimes modifies the 'From'
		_from_email = self.mail.get("X-Original-From") or self.mail["From"]
		_reply_to = self.mail.get("Reply-To")
		if _reply_to and not frappe.db.get_value('Email Account', {"email_id":_reply_to}, 'email_id'):
			self.from_email = _reply_to
		else:
			self.from_email = extract_email_id(_from_email)
		
		if self.from_email:
			self.from_email = self.from_email.lower()

		#self.from_real_name = email.utils.parseaddr(_from_email)[0]

		_from_real_name = email.Header.decode_header(email.utils.parseaddr(_from_email)[0])
		self.from_real_name = email.Header.decode_header(email.utils.parseaddr(_from_email)[0])[0][0] or ""

		try:
			if _from_real_name[0][1]:
				self.from_real_name = self.from_real_name.decode(_from_real_name[0][1])
			else:
				# assume that the encoding is utf-8
				self.from_real_name = self.from_real_name.decode("utf-8")
		except UnicodeDecodeError,e:
			print e
			pass
コード例 #8
0
ファイル: receive.py プロジェクト: maticaZA/basic
    def __init__(self, content):
        import email, email.utils
        import datetime

        self.mail = email.message_from_string(content)

        self.text_content = ''
        self.html_content = ''
        self.attachments = []
        self.parse()
        self.set_content_and_type()
        self.set_subject()

        self.from_email = extract_email_id(self.mail["From"])
        self.from_real_name = email.utils.parseaddr(self.mail["From"])[0]

        if self.mail["Date"]:
            utc = email.utils.mktime_tz(
                email.utils.parsedate_tz(self.mail["Date"]))
            utc_dt = datetime.datetime.utcfromtimestamp(utc)
            self.date = convert_utc_to_user_timezone(utc_dt).strftime(
                '%Y-%m-%d %H:%M:%S')
        else:
            self.date = now()
コード例 #9
0
def execute():
	frappe.reload_doctype('Communication')
	for c in frappe.db.sql("""select name,sender from tabCommunication where communication_type = 'Communication' and sender like '%<%>'""",as_dict=1):
		frappe.db.set_value('Communication', c.name, 'sender',extract_email_id(c.sender) , update_modified=False)
		communication = frappe.get_doc('Communication', c.name)
		match_email_to_contact(communication)