Hi guys, I want to send mail notification to the multiple users of the specific group after a record is created. The mail should be sent to multiple users by checking email id iteratively if the email id is present or not. Can this be accomplished? Can we send the same message to multiple users iteratively or can we get the email of multiple users in email to field in template?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
Hello @Bhuwan khadka,
This is an phython script where you can send mail to multiple user.
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
fromaddr = "your gmail address"
toaddr = ['mail1', 'mail2']
# instance of MIMEMultipart
msg = MIMEMultipart()
# storing the senders email address
msg['From'] = fromaddr
# storing the receivers email address
msg['To'] = ", ".join(toaddr)
print ("\n\n type of msg to", type(msg['To']), type(toaddr))
# storing the subject
msg['Subject'] = "Test Multiple"
# string to store the body of the mail
body = """Hello Good Morning Have a nice day :)
This is just test mail from python"""
# attach the body with the msg instance
msg.attach(MIMEText(body, 'plain'))
p = MIMEBase('application', 'octet-stream')
# encode into base64
encoders.encode_base64(p)
# attach the instance 'p' to instance 'msg'
msg.attach(p)
print ("\n\n msg>>>>>>>>>", msg)
# creates SMTP session
s = smtplib.SMTP('smtp.gmail.com', 587)
# start TLS for security
s.starttls()
# Authentication
s.login(fromaddr, "password")
# Converts the Multipart msg into a string
text = msg.as_string()
try:
s.sendmail(fromaddr, toaddr, text)
print ("\n\nserver>>>>>>>>>", s)
print ("successfully sent email to%s:" % (toaddr))
except:
print ('error sending mail')
Can you please mark this as resolved if you are satisfied with my answer.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
3
Oct 23
|
5977 | ||
|
1
Sep 23
|
1968 | ||
|
1
May 23
|
1004 | ||
|
2
Apr 23
|
1377 | ||
|
1
Mar 23
|
996 |
Hello @Bhuwan khadka,
Can i know In which module you want to use this funtionality.?
Mr. @Aktiv I want to use on my own custom module. I want to send an email to the user of the group users whenever a record is created.