Skip to Content
Menu
This question has been flagged
4 Replies
3584 Views

via Automated Action, server Action, mail template , Is it possible??

Avatar
Discard
Best Answer

HI,
If you need to send email when the form submits,
try in your controller where the action is routed
ie form action="/xxx"
try

@http.route("/xxx", auth='public')
def send_mail_on_action_submit(self,**post):
#get the values and perform actions from post
     mail_obj.send() or use send_mail() function
Avatar
Discard
Best Answer

Yes Sama it is possible. See the python code

Example

import smtplib

sender = 'username'
receivers = 'destinations'
message = """hai         """

smtpObj = smtplib.SMTP(host='smtp.gmail.com', port=587) 
smtpObj.ehlo()
smtpObj.starttls()
smtpObj.ehlo()
smtpObj.login(user="username", password="password") 
smtpObj.sendmail(sender, receivers, message
print "Successfully sent email

All the best !

Avatar
Discard
Author

thanks, I do not know this method, via the user interface if you can explain to me that, for example,in email template form, How to set our fields(from , to ,..)????

Suppose source is foo@gmail.com and destination is bar@gmail.com

Then

sender = 'foo@gmail.com' # you can use sender = self.field_name

receivers = 'bar@gmail.com'

...

...

smtpObj.login(user="foo@gmail.com", password="password of foo@gmail.com")

...

Best Answer

You'll find a similar examples in this post: How to send an email after login?

and in this:  How to send an email via python with the new API ?

Avatar
Discard