mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 18:58:01 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			38 lines
		
	
	
		
			710 B
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			710 B
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/env python3
 | |
| import smtplib
 | |
| from email.message import EmailMessage
 | |
| import sys
 | |
| 
 | |
| def writeEmail(emailBody):
 | |
| 	msg = EmailMessage()
 | |
| 	msg.set_content(emailBody)
 | |
| 	return msg
 | |
| 
 | |
| 
 | |
| def sendEmail(email, sender, recipient, subject, smtpServer='localhost'):
 | |
| 	email['Subject'] = subject
 | |
| 	email['From'] = sender
 | |
| 	email['To'] = recipient
 | |
| 
 | |
| 	try:
 | |
| 		s = smtplib.SMTP(smtpServer)
 | |
| 		s.send_message(email)
 | |
| 		s.quit()
 | |
| 		return True
 | |
| 	except exception:
 | |
| 		print("Send Failed, {}".format(exception))
 | |
| 		sys.exit(2)
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| #body = "Hello This Is A Test"
 | |
| #subject = "Test Email"
 | |
| #recipient = "logan.lipke@candelatech.com"
 | |
| #sender = "lanforge@candelatech.com"
 | |
| 
 | |
| #email = writeEmail(body)
 | |
| 
 | |
| #sendEmail(email, sender, recipient, subject)
 | 
