Python django.conf.settings.EMAIL_PORT Examples

The following are 6 code examples for showing how to use django.conf.settings.EMAIL_PORT(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module django.conf.settings , or try the search function .

Example 1
Project: Servo   Author: fpsw   File:    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
def send_table(sender, recipient, subject, table, send_empty=False):
    if send_empty is False and table.has_body() is False:

    except Exception:

    config = Configuration.conf()
    host, port = Configuration.get_smtp_server()

    settings.EMAIL_HOST = host
    settings.EMAIL_PORT = int(port)
    settings.EMAIL_USE_TLS = config.get('smtp_ssl')
    settings.EMAIL_HOST_USER = config.get('smtp_user')
    settings.EMAIL_HOST_PASSWORD = config.get('smtp_password')

    send_mail(subject, unicode(table), sender, [recipient], fail_silently=False) 
Example 2
Project: GTDWeb   Author: lanbing510   File:    License: GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, host=None, port=None, username=None, password=None,
                 use_tls=None, fail_silently=False, use_ssl=None, timeout=None,
                 ssl_keyfile=None, ssl_certfile=None,
        super(EmailBackend, self).__init__(fail_silently=fail_silently) = host or settings.EMAIL_HOST
        self.port = port or settings.EMAIL_PORT
        self.username = settings.EMAIL_HOST_USER if username is None else username
        self.password = settings.EMAIL_HOST_PASSWORD if password is None else password
        self.use_tls = settings.EMAIL_USE_TLS if use_tls is None else use_tls
        self.use_ssl = settings.EMAIL_USE_SSL if use_ssl is None else use_ssl
        self.timeout = settings.EMAIL_TIMEOUT if timeout is None else timeout
        self.ssl_keyfile = settings.EMAIL_SSL_KEYFILE if ssl_keyfile is None else ssl_keyfile
        self.ssl_certfile = settings.EMAIL_SSL_CERTFILE if ssl_certfile is None else ssl_certfile
        if self.use_ssl and self.use_tls:
            raise ValueError(
                "EMAIL_USE_TLS/EMAIL_USE_SSL are mutually exclusive, so only set "
                "one of those settings to True.")
        self.connection = None
        self._lock = threading.RLock() 
Example 3
Project: luscan-devel   Author: blackye   File:    License: GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, host=None, port=None, username=None, password=None,
                 use_tls=None, fail_silently=False, **kwargs):
        super(EmailBackend, self).__init__(fail_silently=fail_silently) = host or settings.EMAIL_HOST
        self.port = port or settings.EMAIL_PORT
        if username is None:
            self.username = settings.EMAIL_HOST_USER
            self.username = username
        if password is None:
            self.password = settings.EMAIL_HOST_PASSWORD
            self.password = password
        if use_tls is None:
            self.use_tls = settings.EMAIL_USE_TLS
            self.use_tls = use_tls
        self.connection = None
        self._lock = threading.RLock() 
Example 4
Project: helfertool   Author: helfertool   File:    License: GNU Affero General Public License v3.0 6 votes vote down vote up
def connect(self):
        Connect to SMTP server.
        if self._connection:
            raise MailHandlerError("SMTP connection already opened")

            if settings.EMAIL_USE_SSL:
                self._connection = smtplib.SMTP_SSL(settings.EMAIL_HOST, settings.EMAIL_PORT)
                self._connection = smtplib.SMTP(settings.EMAIL_HOST, settings.EMAIL_PORT)

            if settings.EMAIL_USE_TLS:
        except smtplib.SMTPException:
            raise MailHandlerError("Invalid hostname, port or TLS settings for SMTP")

            if settings.EMAIL_HOST_USER and settings.EMAIL_HOST_PASSWORD:
                self._connection.login(settings.EMAIL_HOST_USER, settings.EMAIL_HOST_PASSWORD)
        except smtplib.SMTPException:
            raise MailHandlerError("Invalid username or password for SMTP") 
Example 5
Project: django_mail_admin   Author: Bearle   File:    License: MIT License 6 votes vote down vote up
def setUp(self):

        self._ALLOWED_MIMETYPES = get_allowed_mimetypes()
        self._TEXT_STORED_MIMETYPES = get_text_stored_mimetypes()

        self.mailbox = Mailbox.objects.create(from_email='')

        self.test_account = os.environ.get('EMAIL_ACCOUNT')
        self.test_password = os.environ.get('EMAIL_PASSWORD')
        self.test_smtp_server = os.environ.get('EMAIL_SMTP_SERVER')
        self.test_from_email = ''

        self.maximum_wait_seconds = 60 * 5

        settings.EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
        settings.EMAIL_HOST = self.test_smtp_server
        settings.EMAIL_PORT = 587
        settings.EMAIL_HOST_USER = self.test_account
        settings.EMAIL_HOST_PASSWORD = self.test_password
        settings.EMAIL_USE_TLS = True
        super(EmailMessageTestCase, self).setUp() 
Example 6
Project: DeerU   Author: gojuukaze   File:    License: GNU General Public License v3.0 4 votes vote down vote up
def _send(subject, message, recipient_list,
          email_config=None, html_message=None, fail_silently=False):
    if not email_config:
        blog_config = get_config_by_name(v2_app_config_context['v2_blog_config']).v2_real_config
        email_config = blog_config['email']

    username = email_config.get('username', None) or settings.EMAIL_HOST_USER
    password = email_config.get('password', None)
    if password:
        password = descrypt(unsign(password))
        password = settings.EMAIL_HOST_PASSWORD
    smtp = email_config.get('smtp', None) or settings.EMAIL_HOST
    port = email_config.get('port', None) or settings.EMAIL_PORT
    secure = email_config.get('secure', None)
    if not secure:
        if settings.EMAIL_USE_TLS:
            secure = 'tls'
        elif settings.EMAIL_USE_SSL:
            secure = 'ssl'
    if not username or not password or not smtp or not port:

    kwargs = {
        'host': smtp,
        'port': port,
        'username': username,
        'password': password,
        'fail_silently': fail_silently

    if secure == 'tls':
        kwargs['use_tls'] = True
    elif secure == 'ssl':
        kwargs['use_ssl'] = True

    connection = EmailBackend(**kwargs)
    mail = EmailMultiAlternatives(subject, message, username, recipient_list, connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')

    a= mail.send()