218
def _get_outgoing_server(self, cursor, user, ids, context=None):
220
Returns the Out Going Connection (SMTP) object
222
@attention: DO NOT USE except_osv IN THIS METHOD
223
@param cursor: Database Cursor
224
@param user: ID of current user
225
@param ids: ID/list of ids of current object for
226
which connection is required
227
First ID will be chosen from lists
228
@param context: Context
230
@return: SMTP server object or Exception
232
#Type cast ids to integer
233
if type(ids) == list:
235
this_object = self.browse(cursor, user, ids, context)
237
if this_object.smtpserver and this_object.smtpport:
239
if this_object.smtpssl:
240
serv = smtplib.SMTP_SSL(this_object.smtpserver, this_object.smtpport)
242
serv = smtplib.SMTP(this_object.smtpserver, this_object.smtpport)
243
if this_object.smtptls:
247
except Exception, error:
250
if serv.has_extn('AUTH') or this_object.smtpuname or this_object.smtppass:
251
serv.login(this_object.smtpuname, this_object.smtppass)
252
except Exception, error:
219
def _get_outgoing_server(self, cursor, user, account_id, context=None):
220
"""Returns the Out Going Connection (SMTP) object
223
DO NOT USE except_osv IN THIS METHOD
225
:param cursor: Database Cursor
226
:param user: ID of current user
227
:param account_id: ID of email account
228
:param context: Context
230
:return: SMTP server object
232
if type(account_id) == list:
234
"Support for passing list of ids to _get_outgoing_server "
235
"will be deprecated in 0.8", DeprecationWarning
237
account_id = account_id[0]
239
account = self.browse(cursor, user, account_id, context)
242
raise Exception(_("Connection for the given ID does not exist"))
243
if not (account.smtpserver and account.smtpport):
255
244
raise Exception(_("SMTP SERVER or PORT not specified"))
256
raise Exception(_("Core connection for the given ID does not exist"))
247
server = smtplib.SMTP_SSL(account.smtpserver, account.smtpport)
249
server = smtplib.SMTP(account.smtpserver, account.smtpport)
256
if server.has_extn('AUTH') or account.smtpuname or account.smtppass:
258
account.smtpuname.encode('UTF-8'),
259
account.smtppass.encode('UTF-8')
258
264
def check_outgoing_connection(self, cursor, user, ids, context=None):