Skip to content

Set login name as default email from address

We use in many place the [email] from as fallback value when sending email. But it does not have a default value. So when calling sendmail without a from_addr, smtplib fails with:

Traceback (most recent call last):                   
  File "/usr/local/lib/python3.7/dist-packages/trytond/sendmail.py", line 40, in sendmail                   
    senderrs = server.sendmail(from_addr, to_addrs, msg.as_string())                   
  File "/usr/lib/python3.7/smtplib.py", line 861, in sendmail                   
    (code, resp) = self.mail(from_addr, esmtp_opts)                   
  File "/usr/lib/python3.7/smtplib.py", line 534, in mail                   
    self.putcmd("mail", "FROM:%s%s" % (quoteaddr(sender), optionlist))                   
  File "/usr/lib/python3.7/smtplib.py", line 153, in quoteaddr                   
    if addrstring.strip().startswith('<'):                   
AttributeError: 'NoneType' object has no attribute 'strip'                   

Merge request reports