File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+ import smtplib
2
+ import ssl
3
+ from email .message import EmailMessage
4
+
5
+ # Define email sender and receiver
6
+ email_sender = 'write-email-here'
7
+ email_password = 'write-password-here'
8
+ email_receiver = 'write-email-receiver-here'
9
+
10
+ # Set the subject and body of the email
11
+ subject = 'Check out my new video!'
12
+ body = """
13
+ I've just published a new video on YouTube: https://youtu.be/2cZzP9DLlkg
14
+ """
15
+
16
+ em = EmailMessage ()
17
+ em ['From' ] = email_sender
18
+ em ['To' ] = email_receiver
19
+ em ['Subject' ] = subject
20
+ em .set_content (body )
21
+
22
+ # Add SSL (layer of security)
23
+ context = ssl .create_default_context ()
24
+
25
+ # Log in and send the email
26
+ with smtplib .SMTP_SSL ('smtp.gmail.com' , 465 , context = context ) as smtp :
27
+ smtp .login (email_sender , email_password )
28
+ smtp .sendmail (email_sender , email_receiver , em .as_string ())
You can’t perform that action at this time.
0 commit comments