This question has been flagged
2 Replies
2943 Views

this is my code:



def send_mail(self, cr, uid, ids, context=None):

email_template_obj = self.pool.get('email.template')

template_ids = email_template_obj.search(cr, uid, [('model_id.model', '=', 'sales_order')], context=context)

print template_ids

if template_ids:

values = email_template_obj.generate_email(cr, uid, template_ids[0], ids[0], context=context)

"""values['subject'] = subject

values['email_to'] = inian@rcktechiees.com

values['body_html'] = body_html

values['body'] = body_html"""

values['res_id'] = False

mail_mail_obj = self.pool.get('mail.mail')

msg_id = mail_mail_obj.create(cr, uid, values, context=context)

if msg_id:

mail_mail_obj.send(cr, uid, [msg_id], context=context)

return True




sender = 'ranjith'

receivers = 'inian'

message = """hai

"""

smtpObj = smtplib.SMTP(host='smtp.gmail.com', port=587)

smtpObj.ehlo()

smtpObj.starttls()

smtpObj.ehlo()

smtpObj.login(user="ranjith@rcktechiees.com", password="ranjith6795")

smtpObj.sendmail(sender, receivers, message)

print "Successfully sent email"




sender = str(self.from_id)

receiver = str(self.email_id)

message = str(self.leave_reason)

try:

smtpObj = smtplib.SMTP(host='smtp.gmail.com', port=587)

smtpObj.ehlo()

smtpObj.starttls()

smtpObj.ehlo()

username = str(self.from_id)

pwd = str(self.mail_password)

smtpObj.login(user="ranjith@rcktechiees", password="*******")

smtpObj.sendmail(sender, receiver, message)

smtpObj.quit()

self.state = 'waiting'

print "success"

except SMTPException:

print "error"



no error in this code but no response for sending a mail // what should i have to do for it ? please any one help me to rectify my problem ,

thanks all

Avatar
Discard
Best Answer

hello please check this link i think it help you

http://findnerd.com/list/view/How-to-send-mail-in-next-level-in-workflow-in-OpenERPOdoo-8/21369/


Avatar
Discard
Best Answer

After send email please go to Settings/Technical/Email/Emails to check your email status.

Avatar
Discard