I am working on a big project, that includes a database for remembering users. il skip the details, but my client wants me to include a function by wich he can backup all the user data and other files.
I was thinking of a email, (since the project is a android app) and I was trying to figure out how you could send a attachement (i.e a .db sqlite3 file) in a email. I know theres alot of similair questions around over here, but all of the answers to this question gives me a error. here is the closest that I got:
This program sends a email without a attachment:
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
boodskap = MIMEText("Toekomsweb Epos toets", 'plain')
van_adres = "from adres"
na_adres = "to adres"
epos_liggaam = MIMEMultipart('alternatief')
epos_liggaam['Subject'] = "Toets"
epos_liggaam['From'] = van_adres
epos_liggaam['To'] = na_adres
epos_liggaam.attach(boodskap)
mail = smtplib.SMTP('smtp.gmail.com',587)
mail.ehlo()
mail.starttls()
mail.login(van_adres,'PASSWORD')
mail.sendmail(van_adres,na_adres,epos_liggaam.as_string())
mail.close()
print("succes!")
please excuse my poor variable naming, its not in english.
any help on sending a attachment?
Thanks!