Sure. It is just a little quick & dirty python code that I added as a shell command to homeassistant:
#!/usr/bin/python
# coding: utf8
import json, smtplib, datetime
sender='XXX'
reciever='YYY'
account='ZZZ'
password='BBB'
with open('PATHTOHOMEASSISTANT/.shopping_list.json') as data_file:
shoppingListData = json.load(data_file)
# build message
content = u"Shopping list:\n"
for entry in shoppingListData:
if not entry['complete']:
content += u"- %s\n" % entry['name']
content += u"\nThank you for shopping!"
mail=smtplib.SMTP('smtp.gmail.com',587)
mail.ehlo()
mail.starttls()
mail.login(account,password)
message = """From: %s\nTo: %s\nSubject: %s\n\n%s""" % (sender, reciever, "Shopping list", content)
mail.sendmail(sender,reciever,message.encode('utf-8'))
mail.close()
The code was tested using gmail. However it should work with other email providers by replacing the SMTP server accordingly. You need to enter the sender email address, the receiver email address and your mail account information that are hard coded (there certainly is room for improvements )