I tried to follow the steps in https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-14-04
but when I am in my DigOcean droplet and I try to pip install postfix I get ERROR: Conld not find a version that satisfies the requirement postfix (from versions: none).
I also tried to follow the steps in https://www.rosehosting.com/blog/how-to-setup-mail-server-with-virtual-domains-using-postfix-dovecot-and-opendkim/ and I entered command ufw allow 587 with response: Rules updated Rules updated (v6), but when I enter ufw app list all I get is Available applications: OpenSSH I have already installed mailutils the code I’m trying to run is this (which works fine from my local laptop, just not from code running on my DO droplet). What I’m trying to achieve is sending updates to myself in my email to keep abreast of what’s happening in my droplet program.
import smtplib import mimetypes from email.message import EmailMessage def send_mail(body_msg, attmnt_file_loc=None): mail_obj = EmailMessage() mail_obj['Subject'] = 'This email contains an attachment' mail_obj['From'] = "firstname.lastname@example.org" mail_obj['To'] = 'email@example.com' mail_obj.set_content(body_msg) if attmnt_file_loc!=None: with open(attmnt_file_loc, 'rb') as fp: file_data = fp.read() maintype, _, subtype = (mimetypes.guess_type(attmnt_file_loc) or 'application/octet-stream').partition("/") mail_obj.add_attachment(file_data, maintype=maintype, subtype=subtype, filename=attmnt_file_loc) s = smtplib.SMTP('smtp.gmail.com', 587) s.starttls() s.login("firstname.lastname@example.org", "mygmailpassword") s.send_message(mail_obj) s.quit()
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Click below to sign up and get $200 of credit to try our products over 60 days!