Eddie
2 years ago
3 changed files with 109 additions and 0 deletions
@ -0,0 +1,19 @@ |
|||||||
|
import requests, os |
||||||
|
from dotenv import load_dotenv |
||||||
|
load_dotenv() |
||||||
|
pw = os.getenv('BOT') |
||||||
|
|
||||||
|
headers = { |
||||||
|
|
||||||
|
'Content-Type': 'application/json', |
||||||
|
|
||||||
|
'Accept': 'application/json', |
||||||
|
|
||||||
|
'OCS-APIRequest': 'true', |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
data = '{"token": "xzntzmuh", "message": "test"}' |
||||||
|
|
||||||
|
response = requests.post('https://cloud1.sommerschein.de/ocs/v2.php/apps/spreed/api/v1/chat/xzntzmuh', headers=headers, data=data, auth=('Maily', 'pw')) |
||||||
|
print(response.content) |
@ -0,0 +1,66 @@ |
|||||||
|
import imaplib, email, os |
||||||
|
from dotenv import load_dotenv |
||||||
|
|
||||||
|
complexSearch1 = "UNANSWERED SENTSINCE 01-Sep-2022" |
||||||
|
|
||||||
|
load_dotenv() |
||||||
|
pw = os.getenv('PASSWORD') |
||||||
|
server ="w00e1ce2.kasserver.com" |
||||||
|
username ="booking@sommerschein.de" |
||||||
|
|
||||||
|
# Connect to inbox |
||||||
|
imap_server = imaplib.IMAP4_SSL(host=server) |
||||||
|
imap_server.login(username, pw) |
||||||
|
imap_server.select() # Default is `INBOX` |
||||||
|
|
||||||
|
contacts = [] |
||||||
|
|
||||||
|
# Find all emails in inbox |
||||||
|
_, message_numbers_raw = imap_server.search(None, complexSearch1) |
||||||
|
for message_number in message_numbers_raw[0].split(): |
||||||
|
_, msg = imap_server.fetch(message_number, '(RFC822)') |
||||||
|
|
||||||
|
# Parse the raw email message in to a convenient object |
||||||
|
message = email.message_from_bytes(msg[0][1]) |
||||||
|
contact = message['from'].lower() |
||||||
|
if contact not in contacts: |
||||||
|
contacts.append(contact) |
||||||
|
""" |
||||||
|
print('== Email message =====') |
||||||
|
# print(message) # print FULL message |
||||||
|
print('== Email details =====') |
||||||
|
print(f'From: {message["from"]}') |
||||||
|
|
||||||
|
|
||||||
|
print(f'To: {message["to"]}') |
||||||
|
print(f'Cc: {message["cc"]}') |
||||||
|
print(f'Bcc: {message["bcc"]}') |
||||||
|
print(f'Urgency (1 highest 5 lowest): {message["x-priority"]}') |
||||||
|
print(f'Object type: {type(message)}') |
||||||
|
print(f'Content type: {message.get_content_type()}') |
||||||
|
print(f'Content disposition: {message.get_content_disposition()}') |
||||||
|
print(f'Multipart?: {message.is_multipart()}') |
||||||
|
# If the message is multipart, it basically has multiple emails inside |
||||||
|
# so you must extract each "submail" separately. |
||||||
|
if message.is_multipart(): |
||||||
|
print('Multipart types:') |
||||||
|
for part in message.walk(): |
||||||
|
print(f'- {part.get_content_type()}') |
||||||
|
multipart_payload = message.get_payload() |
||||||
|
for sub_message in multipart_payload: |
||||||
|
# The actual text/HTML email contents, or attachment data |
||||||
|
print(f'Payload\n{sub_message.get_payload()}') |
||||||
|
else: # Not a multipart message, payload is simple string |
||||||
|
print(f'Payload\n{message.get_payload()}') |
||||||
|
# You could also use `message.iter_attachments()` to get attachments only |
||||||
|
|
||||||
|
for c in contacts: |
||||||
|
print(c) |
||||||
|
""" |
||||||
|
for c in contacts: |
||||||
|
contact = c.split('<') |
||||||
|
if len(contact) == 2: |
||||||
|
contact = contact[1].split('>') |
||||||
|
print(contact[0]) |
||||||
|
else: |
||||||
|
print(contact[0]) |
@ -0,0 +1,24 @@ |
|||||||
|
# import the modules |
||||||
|
import imaplib |
||||||
|
import email |
||||||
|
from email.header import decode_header |
||||||
|
import webbrowser |
||||||
|
import os |
||||||
|
from dotenv import load_dotenv |
||||||
|
import time |
||||||
|
# load env file |
||||||
|
load_dotenv() |
||||||
|
pw = os.getenv('PASSWORD') |
||||||
|
server ="w00e1ce2.kasserver.com" |
||||||
|
username ="booking@sommerschein.de" |
||||||
|
|
||||||
|
# Connect to inbox |
||||||
|
imap_server = imaplib.IMAP4_SSL(host=server) |
||||||
|
imap_server.login(username, pw) |
||||||
|
imap_server.select() # Default is `INBOX` |
||||||
|
|
||||||
|
# Find all emails in inbox and print out the raw email data |
||||||
|
_, message_numbers_raw = imap_server.search(None, 'ALL') |
||||||
|
for message_number in message_numbers_raw[0].split(): |
||||||
|
_, msg = imap_server.fetch(message_number, '(RFC822)') |
||||||
|
print(msg[0][1]) |
Loading…
Reference in new issue