-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnotification.py
More file actions
28 lines (22 loc) · 803 Bytes
/
Copy pathnotification.py
File metadata and controls
28 lines (22 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import smtplib
from email.mime.text import MIMEText
def send_alert(transaction_details):
sender = 'anshumansbi@gmail.com'
receiver = 'xyz_customer@gmail.com'
subject = 'Fraudulent Transaction Detected'
body = f'Alert! A fraudulent transaction has been detected:\n{transaction_details}'
msg = MIMEText(body)
msg['Subject'] = subject
msg['From'] = sender
msg['To'] = receiver
with smtplib.SMTP('smtp.gmail.com', 587) as server:
server.starttls()
server.login(sender, 'your_password')
server.sendmail(sender, receiver, msg.as_string())
# Example usage
transaction_details = {
'Amount': 9839.64,
'Location': '(43.550740883275296, -141.72974723173664)',
'ip_Address': '15.246.64.212'
}
send_alert(transaction_details)