当前位置: 首页>>代码示例>>Python>>正文


Python settings.EMAIL_HOST_USER属性代码示例

本文整理汇总了Python中django.conf.settings.EMAIL_HOST_USER属性的典型用法代码示例。如果您正苦于以下问题:Python settings.EMAIL_HOST_USER属性的具体用法?Python settings.EMAIL_HOST_USER怎么用?Python settings.EMAIL_HOST_USER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在django.conf.settings的用法示例。


在下文中一共展示了settings.EMAIL_HOST_USER属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: send_table

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import EMAIL_HOST_USER [as 别名]
def send_table(sender, recipient, subject, table, send_empty=False):
    if send_empty is False and table.has_body() is False:
        return

    try:
        validate_email(sender)
        validate_email(recipient)
    except Exception:
        return

    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) 
开发者ID:fpsw,项目名称:Servo,代码行数:22,代码来源:cron.py

示例2: __init__

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import EMAIL_HOST_USER [as 别名]
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,
                 **kwargs):
        super(EmailBackend, self).__init__(fail_silently=fail_silently)
        self.host = 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() 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:22,代码来源:smtp.py

示例3: send_confirmation_email

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import EMAIL_HOST_USER [as 别名]
def send_confirmation_email(user: PolarisUser, account: PolarisStellarAccount):
    """
    Sends a confirmation email to user.email

    In a real production deployment, you would never want to send emails
    as part of the request/response cycle. Instead, use a job queue service
    like Celery. This reference server is not intended to handle heavy
    traffic so we are making an exception here.
    """
    args = urlencode({"token": account.confirmation_token, "email": user.email})
    url = f"{settings.HOST_URL}{reverse('confirm_email')}?{args}"
    try:
        send_mail(
            _("Reference Anchor Server: Confirm Email"),
            # email body if the HTML is not rendered
            _("Confirm your email by pasting this URL in your browser: %s") % url,
            server_settings.EMAIL_HOST_USER,
            [user.email],
            html_message=render_to_string(
                "confirmation_email.html",
                {"first_name": user.first_name, "confirmation_url": url},
            ),
        )
    except SMTPException as e:
        logger.error(f"Unable to send email to {user.email}: {e}") 
开发者ID:stellar,项目名称:django-polaris,代码行数:27,代码来源:integrations.py

示例4: contact

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import EMAIL_HOST_USER [as 别名]
def contact(request):
    contact_form = Contact(request.POST or None)

    context = {
        "title": "Contact",
        "contact_form": contact_form,
    }

    if contact_form.is_valid():
        sender = contact_form.cleaned_data.get("sender")
        subject = contact_form.cleaned_data.get("subject")
        from_email = contact_form.cleaned_data.get("email")
        message = contact_form.cleaned_data.get("message")
        message = 'Sender:  ' + sender + '\nFrom:  ' + from_email + '\n\n' + message
        send_mail(subject, message, settings.EMAIL_HOST_USER, [settings.EMAIL_HOST_USER], fail_silently=True)
        success_message = "We appreciate you contacting us, one of our Customer Service colleagues will get back" \
                          " to you within a 24 hours."
        messages.success(request, success_message)

        return redirect(reverse('contact'))

    return render(request, "users/contact.html", context) 
开发者ID:avuletica,项目名称:eLearning,代码行数:24,代码来源:views.py

示例5: __init__

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import EMAIL_HOST_USER [as 别名]
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)
        self.host = host or settings.EMAIL_HOST
        self.port = port or settings.EMAIL_PORT
        if username is None:
            self.username = settings.EMAIL_HOST_USER
        else:
            self.username = username
        if password is None:
            self.password = settings.EMAIL_HOST_PASSWORD
        else:
            self.password = password
        if use_tls is None:
            self.use_tls = settings.EMAIL_USE_TLS
        else:
            self.use_tls = use_tls
        self.connection = None
        self._lock = threading.RLock() 
开发者ID:blackye,项目名称:luscan-devel,代码行数:21,代码来源:smtp.py

示例6: send_mail_async

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import EMAIL_HOST_USER [as 别名]
def send_mail_async(*args, **kwargs):
    """ Using celery to send email async

    You can use it as django send_mail function

    Example:
    send_mail_sync.delay(subject, message, from_mail, recipient_list, fail_silently=False, html_message=None)

    Also you can ignore the from_mail, unlike django send_mail, from_email is not a require args:

    Example:
    send_mail_sync.delay(subject, message, recipient_list, fail_silently=False, html_message=None)
    """
    if len(args) == 3:
        args = list(args)
        args[0] = settings.EMAIL_SUBJECT_PREFIX + args[0]
        args.insert(2, settings.EMAIL_HOST_USER)
        args = tuple(args)

    try:
        send_mail(*args, **kwargs)
    except Exception as e:
        logger.error("Sending mail error: {}".format(e)) 
开发者ID:getway,项目名称:diting,代码行数:25,代码来源:tasks.py

示例7: connect

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import EMAIL_HOST_USER [as 别名]
def connect(self):
        """
        Connect to SMTP server.
        """
        if self._connection:
            raise MailHandlerError("SMTP connection already opened")

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

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

        try:
            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") 
开发者ID:helfertool,项目名称:helfertool,代码行数:25,代码来源:forwarder.py

示例8: setUp

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import EMAIL_HOST_USER [as 别名]
def setUp(self):

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

        self.mailbox = Mailbox.objects.create(from_email='from@example.com')

        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 = 'nobody@nowhere.com'

        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() 
开发者ID:Bearle,项目名称:django_mail_admin,代码行数:26,代码来源:test_mailbox_base.py

示例9: send_sms_smtp

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import EMAIL_HOST_USER [as 别名]
def send_sms_smtp(self, config, recipient):
        """
        Sends SMS through SMTP gateway
        """
        recipient = recipient.replace(' ', '')
        settings.EMAIL_HOST = config.get('smtp_host')
        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(recipient, self.body, self.sender, [config['sms_smtp_address']]) 
开发者ID:fpsw,项目名称:Servo,代码行数:13,代码来源:note.py

示例10: track_user_activity

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import EMAIL_HOST_USER [as 别名]
def track_user_activity(form: forms.Form, transaction: Transaction):
        """
        Creates a PolarisUserTransaction object, and depending on the form
        passed, also creates a new PolarisStellarAccount and potentially a
        new PolarisUser. This function ensures an accurate record of a
        particular person's activity.
        """
        if isinstance(form, KYCForm):
            data = form.cleaned_data
            user = PolarisUser.objects.filter(email=data.get("email")).first()
            if not user:
                user = PolarisUser.objects.create(
                    first_name=data.get("first_name"),
                    last_name=data.get("last_name"),
                    email=data.get("email"),
                )

            account = PolarisStellarAccount.objects.create(
                account=transaction.stellar_account, user=user
            )
            if server_settings.EMAIL_HOST_USER:
                send_confirmation_email(user, account)
        else:
            try:
                account = PolarisStellarAccount.objects.get(
                    account=transaction.stellar_account
                )
            except PolarisStellarAccount.DoesNotExist:
                raise RuntimeError(
                    f"Unknown address: {transaction.stellar_account}, KYC required."
                )

        PolarisUserTransaction.objects.get_or_create(
            account=account, transaction=transaction
        ) 
开发者ID:stellar,项目名称:django-polaris,代码行数:37,代码来源:integrations.py

示例11: check_kyc

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import EMAIL_HOST_USER [as 别名]
def check_kyc(transaction: Transaction, post_data=None) -> Optional[Dict]:
        """
        Returns a KYCForm if there is no record of this stellar account,
        otherwise returns None.
        """
        account = PolarisStellarAccount.objects.filter(
            account=transaction.stellar_account
        ).first()
        if not account:  # Unknown stellar account, get KYC info
            if post_data:
                form = KYCForm(post_data)
            else:
                form = KYCForm()
            return {
                "form": form,
                "icon_label": _("Stellar Development Foundation"),
                "title": _("Polaris KYC Information"),
                "guidance": (
                    _(
                        "We're legally required to know our customers. "
                        "Please enter the information requested."
                    )
                ),
            }
        elif server_settings.EMAIL_HOST_USER and not account.confirmed:
            return {
                "title": CONFIRM_EMAIL_PAGE_TITLE,
                "guidance": _(
                    "We sent you a confirmation email. Once confirmed, "
                    "continue on this page."
                ),
                "icon_label": _("Stellar Development Foundation"),
            }
        else:
            return None 
开发者ID:stellar,项目名称:django-polaris,代码行数:37,代码来源:integrations.py

示例12: send_email_smtp

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import EMAIL_HOST_USER [as 别名]
def send_email_smtp(self, email: EmailMultiAlternatives) -> None:
        from_email = email.from_email
        to = get_forward_address()

        msg = EmailMessage()
        msg['Subject'] = email.subject
        msg['From'] = from_email
        msg['To'] = to

        text = email.body
        html = email.alternatives[0][0]

        # Here, we replace the email addresses used in development
        # with chat.zulip.org, so that web email providers like Gmail
        # will be able to fetch the illustrations used in the emails.
        localhost_email_images_base_uri = settings.ROOT_DOMAIN_URI + '/static/images/emails'
        czo_email_images_base_uri = 'https://chat.zulip.org/static/images/emails'
        html = html.replace(localhost_email_images_base_uri, czo_email_images_base_uri)

        msg.add_alternative(text, subtype="plain")
        msg.add_alternative(html, subtype="html")

        smtp = smtplib.SMTP(settings.EMAIL_HOST)
        smtp.starttls()
        smtp.login(settings.EMAIL_HOST_USER, settings.EMAIL_HOST_PASSWORD)
        smtp.send_message(msg)
        smtp.quit() 
开发者ID:zulip,项目名称:zulip,代码行数:29,代码来源:email_backends.py

示例13: send_email

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import EMAIL_HOST_USER [as 别名]
def send_email(email, new_password):
    if settings.EMAIL_HOST_USER is '' or settings.EMAIL_HOST_PASSWORD is '':
        return {'status' : 'failed', 'message' : 'cannot change password, emailer is offline, please check back later' }
    
    text = "Your new password is: " + new_password
            
    send_mail(
        "New Password",
        text,
        settings.EMAIL_HOST_USER,
        [email],
        fail_silently=False
    )
    return {'status' : 'success', 'message' : 'successfully registered' } 
开发者ID:AcademicsToday,项目名称:academicstoday-django,代码行数:16,代码来源:forgot_password.py

示例14: handle

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import EMAIL_HOST_USER [as 别名]
def handle(self, *args, **options):
        """
            Function iterates through all the messages left for us on the 
            landpage and emails these messages to the contact lists.
        """
        contact_list = ["bartlomiej.mika@gmail.com", "sibrislarenz@gmail.com", "m_poet5@hotmail.com"]
        
        try:
           messages = LandpageContactMessage.objects.all()
        except LandpageContactMessage.DoesNotExist:
           return

        # Send our messages and then delete them from the database.
        for message in messages:
            """
               Please note, since we are using gmail, we need "Access for
               less secure apps" to be "Turned On".
            """
            text = "FROM: " + message.email + "\n"
            text += "NAME: " + message.name + "\n"
            text += "PHONE: " + message.phone + "\n"
            text += "MESSAGE: " + message.message + "\n"
            
            send_mail(
                "Landpage Message",
                text,
                settings.EMAIL_HOST_USER,
                contact_list,
                fail_silently=False)

            message.delete() # Delete our message 
开发者ID:AcademicsToday,项目名称:academicstoday-django,代码行数:33,代码来源:checkinbox.py

示例15: post

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import EMAIL_HOST_USER [as 别名]
def post(self, request, *args, **kwargs):
        context = self.get_context_data()
        if context['form'].is_valid():
            cd = context['form'].cleaned_data
            subject = cd['subject']
            from_email = cd['email']
            message = cd['message']

            try:
                send_mail(
                    subject + " from {}".format(from_email),
                    message,
                    from_email,
                    [settings.EMAIL_HOST_USER]
                )
            except BadHeaderError:
                return HttpResponse('Invalid header found.')

            ctx = {
                'success': """Thankyou, We appreciate that you've
                taken the time to write us.
                We'll get back to you very soon.
                Please come back and see us often."""
            }
            return render(request, self.template_name, ctx)
        return super(generic.TemplateView, self).render_to_response(context) 
开发者ID:agusmakmun,项目名称:Django-Blog-Python-Learning,代码行数:28,代码来源:views.py


注:本文中的django.conf.settings.EMAIL_HOST_USER属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。