Kiwi icon indicating copy to clipboard operation
Kiwi copied to clipboard

Add DEFAULT_FROM_EMAIL to common.py settings

Open okainov opened this issue 9 years ago • 8 comments

Description of problem

common.py settings for email are not full. Field DEFAULT_FROM_EMAIL is missing, but it's required for sending emails. So common.py settings should look like:

EMAIL_HOST = '' EMAIL_PORT = 25 EMAIL_FROM = '<insert_email>' DEFAULT_FROM_EMAIL = '<insert_email>' EMAIL_SUBJECT_PREFIX = '[Kiwi-TCMS] '

Component (web, API, etc)

core

Version or commit hash (if applicable)

latest

How often reproducible

always

okainov avatar Nov 30 '17 09:11 okainov

@atodorov are you sure that it will work w\o EMAIL_FROM? I didn't investigate it, but when I just changed EMAIL_FROM to DEFAULT_FROM_EMAIL, something appeared to be broken, so I had to leave both options

okainov avatar Nov 30 '17 13:11 okainov

@GodfatherThe see the diff in the commit. Kiwi TCMS internally never used DEFAULT_FROM_EMAIL but instead used EMAIL_FROM and also EMAIL_HOST to figure out whether or not to send email.

The commit changes this and makes Kiwi use only DEFAULT_FROM_EMAIL. Depending on the email backend you are using you may still need to configure EMAIL_HOST, EMAIL_PORT, EMAIL_USERNAME, etc.

atodorov avatar Nov 30 '17 14:11 atodorov

@GodfatherThe @atodorov

I added the following settings in the file below: /venv/lib/python3.5/site-packages/tcms/settings/common.py

EMAIL_HOST = 'smtp.xxx.com' EMAIL_PORT = 25 DEFAULT_FROM_EMAIL = '[email protected]' EMAIL_SUBJECT_PREFIX = '[Kiwi-TCMS] '

Then I went back to the website and tried to add a test run, but no email was sent out. I also tried to register a new account and the new account did not receive any email too.

I am wondering if I missed any settings here? Or I need to run some commands after I updated the common.py file to start the email service?

Thanks a lot for your suggestions!

calvinmqc avatar Feb 23 '18 20:02 calvinmqc

@calvinmqc for me it's working good. Could you check the logs from the server\sendmail? Can it be that your smtp server is blocking emails? Did you restart Django after changing settings? BTW modifying the file in Docker directly is not a supposed way. You should modify your code from outside and then make image again.

okainov avatar Feb 24 '18 07:02 okainov

@calvinmqc please see the Django email documentation: https://docs.djangoproject.com/en/2.0/topics/email/#quick-example

there could be tons of things that can go wrong depending on your environment and chosen email backend so consult the logs to get an idea what's happening.

The best way to modify settings is to create a file outside the container and then use the docker-compose.yml file to mount your local file under /venv/lib/python3.5/site-packages/tcms/settings/product.py inside the container.

atodorov avatar Feb 24 '18 08:02 atodorov

@GodfatherThe

Thanks for your comments. I will contact our IT team to verify the SMTP server log file. How do we restart Django in the Kiwi container? My understanding is that Django has been embedded into the Kiwi image?

calvinmqc avatar Feb 26 '18 18:02 calvinmqc

What I meant by "restart" is

  • change sources
  • stop kiwi container
  • redeploy (make image)
  • start container So, restart both container and django. And don't change files inside container, change sources outside.

okainov avatar Feb 26 '18 19:02 okainov

@GodfatherThe @atodorov

Thanks a lot for your help! Once I created a new product.py file outside the container, restart Kwi, it started to work properly!!

BTW, I am using the DEFAULT_FROM_EMAIL setting, EMAIL_FROM is not required.

calvinmqc avatar Feb 26 '18 20:02 calvinmqc