22
22
def send_confirmation_mail (username : str , email : str , token : str ) -> str :
23
23
""" Send the account activation email to the user.
24
24
25
- @ param username: the name of the user
26
- @ param email: the email of the user
27
- @ param token: the token to be used to activate the account
28
- @ return: the message sent to the user
25
+ : param username: the name of the user
26
+ : param email: the email of the user
27
+ : param token: the token to be used to activate the account
28
+ : return: the message sent to the user
29
29
"""
30
30
service : Any = build ('gmail' , 'v1' , credentials = Credentials .from_authorized_user_file (get_config ()))
31
31
message : MIMEMultipart = build_email_core (title = 'PTMD - Account activation' , email = email )
@@ -36,9 +36,9 @@ def send_confirmation_mail(username: str, email: str, token: str) -> str:
36
36
def send_validated_account_mail (username : str , email : str ) -> str :
37
37
""" Send the notification to the user that the account is now active.
38
38
39
- @ param username: the name of the user
40
- @ param email: the email of the user
41
- @ return: the message sent to the user
39
+ : param username: the name of the user
40
+ : param email: the email of the user
41
+ : return: the message sent to the user
42
42
"""
43
43
service : Any = build ('gmail' , 'v1' , credentials = Credentials .from_authorized_user_file (get_config ()))
44
44
message : MIMEMultipart = build_email_core (title = 'PTMD - Your account is now active' , email = email )
@@ -49,8 +49,8 @@ def send_validated_account_mail(username: str, email: str) -> str:
49
49
def send_validation_mail (user : object ) -> str :
50
50
""" Send the notification to the admin that a user account needs activation.
51
51
52
- @ param user: the User class to be used to get the user information
53
- @ return: the message sent to the user
52
+ : param user: the User class to be used to get the user information
53
+ : return: the message sent to the user
54
54
"""
55
55
service : Any = build ('gmail' , 'v1' , credentials = Credentials .from_authorized_user_file (get_config ()))
56
56
message : MIMEMultipart = build_email_core (title = 'PTMD - An account needs to be activated' , email = ADMIN_EMAIL )
@@ -61,9 +61,9 @@ def send_validation_mail(user: object) -> str:
61
61
def build_email_core (title : str , email : str ) -> MIMEMultipart :
62
62
""" Build the core of the email and return a MIMEMultipart object.
63
63
64
- @ param title: the title of the email
65
- @ param email: the email of the user
66
- @ return: the core of the email
64
+ : param title: the title of the email
65
+ : param email: the email of the user
66
+ : return: the core of the email
67
67
"""
68
68
message : MIMEMultipart = MIMEMultipart ()
69
69
message ['Subject' ] = title
@@ -75,9 +75,9 @@ def build_email_core(title: str, email: str) -> MIMEMultipart:
75
75
def send_email (message : MIMEMultipart , service : Any , body : str ) -> str :
76
76
""" Send the email to the user.
77
77
78
- @ param message: the MIMEMultipart object to be used to send the email
79
- @ param service: the service to be used to send the email
80
- @ param body: the body of the email
78
+ : param message: the MIMEMultipart object to be used to send the email
79
+ : param service: the service to be used to send the email
80
+ : param body: the body of the email
81
81
"""
82
82
message .attach (MIMEText (body , 'html' ))
83
83
create_message = {'raw' : urlsafe_b64encode (message .as_bytes ()).decode ()}
@@ -88,10 +88,10 @@ def send_email(message: MIMEMultipart, service: Any, body: str) -> str:
88
88
def send_reset_pwd_email (username : str , email : str , token : str ) -> str :
89
89
""" Send the reset password token to the user.
90
90
91
- @ param username: the name of the user
92
- @ param email: the email of the user
93
- @ param token: the token to be used to reset the account password
94
- @ return: the message sent to the user
91
+ : param username: the name of the user
92
+ : param email: the email of the user
93
+ : param token: the token to be used to reset the account password
94
+ : return: the message sent to the user
95
95
"""
96
96
service : Any = build ('gmail' , 'v1' , credentials = Credentials .from_authorized_user_file (get_config ()))
97
97
message : MIMEMultipart = build_email_core (title = 'PTMD -Reset Password' , email = email )
0 commit comments