-1

I have an ubuntu 18.04lts server set up running my Flask app, and I need to be able to send users a confirmation email to let them create an account. I am using Flask-User to handle account authorization/authentication, and I know it uses Flask-Mail to handle confirmation emails.

There are a bunch of tutorials out there on how to set up flask mail to send emails through gmail, and I was using that for a little while, however that (and other smtp clients) only allows you to send up to (I believe) about 100 emails per day, and I may need to handle more emails than this. I found out about postfix for ubuntu, and I have set that up. However, I can't seem to figure out what configurations I need to pass to my app to make this work.

I have looked at the following question, but it and every other tutorial seem to have the configuration already figured out.

BadHeaderError using Flask with FlaskMail and Postfix on Ubuntu server

Here is an example of what I mean:

In my config.py (I need the ??? entries):

import json

with open('/etc/config.json') as config_file:
    config = json.load(config_file)

class Config:
    MAIL_SERVER = # ??? 
    MAIL_USERNAME = # ???
    MAIL_PASSWORD = # ???
    MAIL_DEFAULT_SENDER = # ???
    MAIL_PORT = # ???
    MAIL_USE_SSL = # ???
    MAIL_USE_TLS = # ???
    SECRET_KEY = config.get('SECRET_KEY')
    SQLALCHEMY_DATABASE_URI = config.get('SQLALCHEMY_DATABASE_URI')
    CSRF_ENABLED = True
    USER_ENABLE_EMAIL = True

I would put most of these variables in my config_file, but I don't know what those values are supposed to be. Supposedly I have postfix configured to support TLS.

I can provide any other relevant info if needed. In my init.py file I just import my configuration from this file.

EDIT: I know you can't give me specific values, and I am not looking for parameters for my machine specifically. I just don't know what relative values I needed in those fields, for example, do I need a username? is it the name of my server? the name of the current system user? is the password the password for my server? no password, since it is local? etc.

Entest89
  • 77
  • 5
  • The ??? are the parameters of your email server, in this case posix server. SERVER use te be 127.0.0.1 user name a machine user (or at least posix user) with its password, the port must be 25 or 587. As it is a local host you can use or not the SSL and TLS, to False, but the most important point is to have postfix up and running and well configured for you domain – Mquinteiro Oct 07 '20 at 20:05

1 Answers1

0

There is not too much I can help you with, as these values are exact the values you configured your Postfix server with.

MAIL_SERVER = # ???

e.g. mail.example.net, or whatever domain your mail server is available at (localhost, ...)

MAIL_USERNAME = # ???

This is the user name for the authentication.

MAIL_PASSWORD = # ???

This is the password for the authentication (the same you would enter e.g. in your mail client when you configure to send emails)

MAIL_DEFAULT_SENDER = # ???

This is an email address, e.g. info@example.net

MAIL_PORT = # ???

The port Postfix is listening, e.g. 25 or 587 or whatever you configured it to.

MAIL_USE_SSL = # ??? MAIL_USE_TLS = # ???

If you use encryption, you have to activate them accordingly. e.g. my mailserver uses TLS so I set MAIL_USE_TLS = True

Jürgen Gmach
  • 5,366
  • 3
  • 20
  • 37
  • Yeah, sorry I guess I didn't make it clear, I am not looking for parameters for my machine specifically. I just didn't know what relative values I needed in those fields, for example, do I need a username? is it the name of my server? the name of the current system user? is the password the password for my server? no password, since it is local? etc. – Entest89 Oct 07 '20 at 22:45
  • The username is the username of the email account, same goes for the password. This depends on how you configured Postfix. If you require no authentication you could omit both values. – Jürgen Gmach Oct 08 '20 at 10:37