I want send email from django application.
I want send an email to my mail id from other username without authentication. Just i used smtp server for the authenticated mail.In the django mail api How it is supposed to send an mail with the local smtp?
As stated on the docs: https://docs.djangoproject.com/en/dev/topics/email/?from=olddocs you need to:
On your settings.py define the following:
EMAIL_HOST = 'localhost'
EMAIL_PORT = 1025
Then, in another shell run the following command:
python -m smtpd -n -c DebuggingServer localhost:1025
That will run a dummy SMTP server, that actually will not send any email but you'll be able to see the output and check if that's correct. If you want to actually send your emails during development, you will need to install a SMTP server like sendmail and use that in your configuration.
Related
I'm facing Authentication unsuccessful error when I try to send mail from Apache Superset.
I checked the document's SMTP integration chapter:https://apache-superset.readthedocs.io/en/latest/installation.html
I changed SMTP_PASSWORD parameter and I entered password manually in my config.py file like SMTP_PASSWORD = "'xxx!!'" (I added '' because my password includes special character like '!'. Also, I tried SMTP_PASSWORD="xx!!" but also I'm getting error.
smtplib.SMTPAuthenticationError: (535, b'5.7.3 Authentication unsuccessful')
I can login with my SMTP user via browser (Exchange). Could you please help me to solve this issue?
Apache Superset version: 1.3.2
Python version:3.8
OS version: RHEL 8
Thanks
You might be able to poke at this by checking your SMTP connection from inside your Superset instance.
From where your Superset instance should be sending the emails, start a Python script and try:
import smtplib
server = smtplib.SMTP('smtpservername.yourdomain', yourportnumber)
If that command fails or hangs indefinitely, you know there's a connection problem. You might try connecting to the GMail SMTP server or another known-to-work set of credentials and seeing if that works to narrow it down.
For instance, if running Superset with docker-compose you would enter the worker container with docker exec -it superset_worker /bin/bash, run python, and try this there.
My scheduled reports were failing and doing this helped me isolate a cause: my Superset instance could not connect to the target unauthenticated SMTP server.
I am looking to have one of my django docker containers setup a smtp backend so I can send input from a contact form to a gmail address as well as possibly send out an email when someone puts in their email to subscribe for updates: https://docs.djangoproject.com/en/1.11/topics/email/#smtp-backend
How do I go about setting up the SMTP server? Is it a separate docker container? How do I set it up?
The email backend is just an imported module. You can just use it like it is described in the docs: https://docs.djangoproject.com/en/1.11/topics/email/#email-backends
Before that, you have to configure the data for the smtp server. You just have to configure the settings, like your smtp host, username and password, etc. Here are the docs to configure it: https://docs.djangoproject.com/en/1.11/topics/email/#smtp-backend
You can use an existing smtp server. If you have a package with a domain you probably have a an email account included.
There is no need for another container. But you can setup your own in a a separate container. There are already some docker-ready solutions present. Here are a few:
https://github.com/namshi/docker-smtp
https://mailu.io/
https://github.com/tomav/docker-mailserver
just do changes in some file
#add it in docker_compose.yml
maildev:
image: maildev/maildev
ports:
- "49180:80"
# add it in your settings.py file
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'maildev'
EMAIL_PORT = 25
# then run docker-compose up -d
# when it done then run docker build -t <your tag Name> .
happy coding.......
refrence link:
[1]: https://melvinkoh.me/configure-and-send-email-in-django-for-both-development-and-production-cjye4y0l7000nuns1m43vstaq
I use Django to send email,everything is OK when running on development environment, which uses command "python manage.py runserver 0.0.0.0:8100". But in the production environment which deployed by nginx+uwsgi+Django do not work.
Here is the code:
#Email settings
EMAIL_HOST='smtp.exmail.qq.com'
EMAIL_PORT='465'
EMAIL_HOST_USER='sender#qq.cn'
EMAIL_HOST_PASSWORD='password'
EMAIL_USE_SSL=True
RECEIVE_EMIAL_LIST=['receiver#qq.com']
send_mail('subject','content',setting.EMAIL_HOST_USER,setting.RECEIVE_EMIAL_LIST, fail_silently=False)
Have you checked that your production environment has the same network settings as the development environment?
Have you tried to ping or telnet the SMTP server from production?
Is possible that the production host is in a DMZ or in a subnet that has restricted access to the SMTP server you are trying to reach.
EMAIL_HOST = 'smtp.qq.com'
change EMAIL_PORT='465' to EMAIL_PORT = 587, with no quotes.
EMAIL_HOST_USER = 'abc#qq.com' # try to use your real email address.
RECEIVE_EMIAL_LIST=['receiver#qq.com'] to RECEIVE_EMIAL_LIST=['receiver#qq.com'**,**] # add a comma at the end of the list is a good habit.
I have to connect to a remote sftp server to upload some files using python 2.7. i have been given a username, password and the authentication key file. when i execute this code:
srv= pysftp.Connection(host='54.172.33.121',username='xxx',password='xxx',private_key='c:\SFTPKey\hajjcoreit.ppk')
i get this error:
BadAuthenticationType: ('Bad authentication type', [u'publickey']) (allowed_types=[u'publickey'])
i can access the server through winSCP though.
Edits in your code
You probably have done something wrong with the hostname. As the proper syntax for pysftp is as
import pysftp
sftp = pysftp.Connection('hostname', username='me', password='secret')
#
# ... do sftp operations
#
sftp.close() # close your connection to hostname
so now this is what you do,
srv=pysftp.Connection('sftp.54.172.33.121',username='xxx',password='xxx',private_key='c:\SFTPKey\hajjcoreit.ppk')
so you won't get any error.Also cross check with the filezilla that the link, uid and password are correct.
I try to send email in Redmine with sendmail method, but I don't receive any email.
Therefore, I tried configuring smtp email setup in Redmine using the following parameters, but I get the error "An error occurred while sending mail (execution expired)".
production:
email_delivery:
delivery_method: :smtp
smtp_settings:
address: "box784.bluehost.com"
port: 465
authentication: :plain
user_name: "username+domain.com"
password: password
enable_starttls_auto: true
my Information:
Environment:
Redmine version 2.1.4.stable
Ruby version 1.8.7 (x86_64-linux)
Rails version 3.2.8
Environment production
Database adapter MySQL
Redmine plugins:
no plugin installed
After a couple of very late nights playing with all the settings in the configuration.yml file, I have finally been able to get email notifications to work with Redmine on Bluehost. Getting it to work with SMTP was a futile exercise, and Bluehost wasn't very helpful with getting it resolved, however I got it working using sendmail. The trick is to add a couple extra parameters, which really should be documented in the Redmine Wiki help. Here is a copy of my configuration.yml file, which works. It's the enable_starttls_auto and authentication settings that make it work (go figure). Make sure you get the spacing right (each indent has 2 spaces):
production:
email_delivery:
delivery_method: :sendmail
sendmail_settings:
arguments: -i
enable_starttls_auto: false
authentication: :none
Finally! Working Sendmail with Redmine on Bluehost!
This configuration works. You can use the test email feature in Redmine to test this.
Source: https://poopcode.com/configure-outlook-email-in-redmine/