File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import os
22import asyncio
3- from dotenv import load_dotenv #
3+ from dotenv import load_dotenv #
44import postmark
55
66
77# Load the variables from the .env file into os.environ
88load_dotenv ()
99
10+
1011async def find ():
1112 server_token : str = os .getenv ("POSTMARK_SERVER_TOKEN" )
12-
13+
1314 try :
14- messages , total = await postmark .messages .Outbound .find (server_token = server_token )
15+ messages , total = await postmark .messages .Outbound .find (
16+ server_token = server_token
17+ )
1518 print (messages )
1619 print (f"Found { total } messages, retrieved { len (messages )} messages." )
1720 if messages :
@@ -22,13 +25,14 @@ async def find():
2225 print (f" DATE: { msg .received_at } " )
2326 else :
2427 print ("No messages found" )
25-
28+
2629 except Exception as e :
2730 print (f"Error: { e } " )
2831
32+
2933async def find_all ():
3034 server_token : str = os .getenv ("POSTMARK_SERVER_TOKEN" )
31-
35+
3236 try :
3337 messages = await postmark .messages .Outbound .find_all (server_token = server_token )
3438 print (f"Found messages, retrieved { len (messages )} messages." )
@@ -40,10 +44,11 @@ async def find_all():
4044 print (f" DATE: { msg .received_at } " )
4145 else :
4246 print ("No messages found" )
43-
47+
4448 except Exception as e :
4549 print (f"Error: { e } " )
4650
51+
4752if __name__ == "__main__" :
48- # asyncio.run(find())
49- asyncio .run (find_all ())
53+ asyncio .run (find ())
54+ # asyncio.run(find_all())
Original file line number Diff line number Diff line change @@ -27,8 +27,11 @@ def validate_formatted_email(v: str) -> str:
2727 """
2828 Validate email fields that may contain formatted strings like "Name" <email@example.com>
2929 """
30- if not v :
31- return v
30+
31+ if v is None : # None
32+ raise ValueError ("Email cannot be None" )
33+ if not v : # Empty string
34+ raise ValueError ("Email cannot be empty" )
3235
3336 # Extract email from formats like: "Name" <email@example.com> or just email@example.com
3437 email_pattern = r'<([^>]+)>|([^\s<>"]+@[^\s<>"]+)'
You can’t perform that action at this time.
0 commit comments