|
28 | 28 | import netsvc
|
29 | 29 | import base64
|
30 | 30 | import time
|
| 31 | +import re |
31 | 32 | from tools.translate import _
|
32 | 33 | import tools
|
33 | 34 | from poweremail_template import get_value
|
@@ -190,8 +191,24 @@ def sav_to_drafts(self, cr, uid, ids, context=None):
|
190 | 191 | def send_mail(self, cr, uid, ids, context=None):
|
191 | 192 | if context is None:
|
192 | 193 | context = {}
|
| 194 | + mailbox_obj = self.pool.get('poweremail.mailbox') |
| 195 | + values = {'folder':'outbox'} |
| 196 | + check_email = True |
| 197 | + |
193 | 198 | mailid = self.save_to_mailbox(cr, uid, ids, context)
|
194 |
| - if self.pool.get('poweremail.mailbox').write(cr, uid, mailid, {'folder':'outbox'}, context): |
| 199 | + |
| 200 | + if len(mailid)>0: |
| 201 | + mail = mailbox_obj.browse(cr, uid, mailid[0], context) |
| 202 | + check_email = mail.pem_to and mailbox_obj.check_email_valid(mail.pem_to) or False |
| 203 | + if mail.pem_cc: |
| 204 | + check_email = check_email and mailbox_obj.check_email_valid(mail.pem_cc) |
| 205 | + if mail.pem_bcc: |
| 206 | + check_email = check_email and mailbox_obj.check_email_valid(mail.pem_bcc) |
| 207 | + |
| 208 | + if not check_email: |
| 209 | + values = {'folder':'drafts'} |
| 210 | + |
| 211 | + if mailbox_obj.write(cr, uid, mailid, values, context): |
195 | 212 | return {'type':'ir.actions.act_window_close' }
|
196 | 213 |
|
197 | 214 | def get_generated(self, cr, uid, ids=None, context=None):
|
|
0 commit comments