本文整理匯總了Python中django.conf.settings.DEFAULT_FROM_EMAIL屬性的典型用法代碼示例。如果您正苦於以下問題:Python settings.DEFAULT_FROM_EMAIL屬性的具體用法?Python settings.DEFAULT_FROM_EMAIL怎麽用?Python settings.DEFAULT_FROM_EMAIL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類django.conf.settings
的用法示例。
在下文中一共展示了settings.DEFAULT_FROM_EMAIL屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: oauth_authorize
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_FROM_EMAIL [as 別名]
def oauth_authorize(request, request_token, callback, params):
"""
The callback view for oauth_provider's OAUTH_AUTHORIZE_VIEW.
"""
consumer = request_token.consumer
consumerinfo = ConsumerInfo.objects.filter(consumer_id=request_token.consumer_id).order_by('-timestamp').first()
form = AuthorizeRequestTokenForm(initial={'oauth_token': request_token.key})
# email the user so we're super-sure they know this is happening
person = get_object_or_404(Person, userid=request.user.username)
manage_url = request.build_absolute_uri(reverse('config:manage_tokens'))
message = EMAIL_INFORM_TEMPLATE.format(consumername=consumer.name, url=manage_url)
send_mail('CourSys access requested', message, settings.DEFAULT_FROM_EMAIL, [person.email()], fail_silently=False)
context = {
'consumer': consumer,
'consumerinfo': consumerinfo,
'form': form,
}
return render(request, 'api/oauth_authorize.html', context)
示例2: email_memo
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_FROM_EMAIL [as 別名]
def email_memo(self):
"""
Emails the registration confirmation email if there is one and if none has been emailed for this registration
before.
"""
# If this registration is waitlisted, don't email!
if self.waitlisted:
return
if 'email' not in self.config and self.event.registration_email_text:
subject = 'Registration Confirmation'
from_email = settings.DEFAULT_FROM_EMAIL
content = self.event.registration_email_text
msg = EmailMultiAlternatives(subject, content, from_email,
[self.email], headers={'X-coursys-topic': 'outreach'})
msg.send()
self.email_sent = content
self.save()
示例3: email_contract
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_FROM_EMAIL [as 別名]
def email_contract(self):
unit = self.posting.unit
try:
contract_email = unit.contract_email_text
content = contract_email.content
subject = contract_email.subject
except TAContractEmailText.DoesNotExist:
content = DEFAULT_EMAIL_TEXT
subject = DEFAULT_EMAIL_SUBJECT
response = HttpResponse(content_type="application/pdf")
response['Content-Disposition'] = 'inline; filename="%s-%s.pdf"' % (self.posting.slug,
self.application.person.userid)
ta_form(self, response)
to_email = self.application.person.email()
if self.posting.contact():
from_email = self.posting.contact().email()
else:
from_email = settings.DEFAULT_FROM_EMAIL
msg = EmailMultiAlternatives(subject, content, from_email,
[to_email], headers={'X-coursys-topic': 'ta'})
msg.attach(('"%s-%s.pdf' % (self.posting.slug, self.application.person.userid)), response.getvalue(),
'application/pdf')
msg.send()
示例4: test_send_expiration_mails
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_FROM_EMAIL [as 別名]
def test_send_expiration_mails(mailoutbox, mocker, now, cluster_factory):
cluster = cluster_factory(
expires_at=now + timedelta(minutes=59), # 1 hours is the cut-off
most_recent_status=models.Cluster.STATUS_WAITING,
)
assert len(mailoutbox) == 0
tasks.send_expiration_mails()
assert len(mailoutbox) == 1
message = mailoutbox[0]
assert message.subject == (
"%sCluster %s is expiring soon!"
% (settings.EMAIL_SUBJECT_PREFIX, cluster.identifier)
)
assert message.from_email == settings.DEFAULT_FROM_EMAIL
assert list(message.to) == [cluster.created_by.email]
cluster.refresh_from_db()
assert cluster.expiration_mail_sent
示例5: handle
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_FROM_EMAIL [as 別名]
def handle(self, **options):
start_time = time.time()
domain = Site.objects.get_current().domain
from_email = settings.DEFAULT_FROM_EMAIL
if hasattr(settings, 'SEND_MESSAGE_FULLTEXT') and settings.SEND_MESSAGE_FULLTEXT:
notify_messages = send_fulltext(domain, from_email)
else:
notify_messages = [send_only_notify(domain, from_email)]
num_sent = 0
sleep_time = 0
for messages in notify_messages:
if messages:
num_sent += send_mass_mail_html(messages)
time.sleep(1)
sleep_time += 1
# logging to cron log
print "Command send_mail_notifications send {0} email(s) and took {1} seconds (sleep {2} seconds)" \
.format(num_sent, time.time() - start_time, sleep_time)
示例6: handle
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_FROM_EMAIL [as 別名]
def handle(self, *args, **options):
email = options["email"]
last_days = options["last_days"]
# today is excluded
end = timezone.now().replace(hour=0, minute=0, second=0, microsecond=0)
start = end - timedelta(days=last_days)
employments = Employment.objects.filter(updated__range=[start, end])
if employments.exists():
from_email = settings.DEFAULT_FROM_EMAIL
subject = "[Timed] Employments changed in last {0} days".format(last_days)
body = template.render({"employments": employments})
message = EmailMessage(
subject=subject,
body=body,
from_email=from_email,
to=[email],
headers=settings.EMAIL_EXTRA_HEADERS,
)
message.send()
示例7: handle
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_FROM_EMAIL [as 別名]
def handle(self, *args, **options):
emails = []
subject = 'Enroll in a course'
date_joined = timezone.now().today() - \
datetime.timedelta(days=options['days'])
users = User.objects.annotate(course_count=Count('courses_joined'))\
.filter(course_count=0,
date_joined__date__lte=date_joined)
for user in users:
message = """Dear {},
We noticed that you didn't enroll in any courses yet.
What are you waiting for?""".format(user.first_name)
emails.append((subject,
message,
settings.DEFAULT_FROM_EMAIL,
[user.email]))
send_mass_mail(emails)
self.stdout.write('Sent {} reminders'.format(len(emails)))
示例8: form_valid
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_FROM_EMAIL [as 別名]
def form_valid(self, form):
user = User.objects.filter(email=self.request.POST.get('email'))
if user:
user = user[0]
subject = "Password Reset"
password = get_random_string(6)
message = '<p>Your Password for the forum account is <strong>'+password + \
'</strong></p><br/><p>Use this credentials to login into <a href="' + \
settings.HOST_URL + '/forum/">forum</a></p>'
to = user.email
from_email = settings.DEFAULT_FROM_EMAIL
Memail([to], from_email, subject, message, email_template_name=None, context=None)
user.set_password(password)
user.save()
data = {
"error": False, "response": "An Email is sent to the entered email id"}
return JsonResponse(data)
else:
data = {
"error": True, "message": "User With this email id doesn't exists!!!"}
return JsonResponse(data)
示例9: send_email
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_FROM_EMAIL [as 別名]
def send_email(to, kind, cc=[], **kwargs):
current_site = Site.objects.get_current()
ctx = {"current_site": current_site, "STATIC_URL": settings.STATIC_URL}
ctx.update(kwargs.get("context", {}))
subject = "[%s] %s" % (
current_site.name,
render_to_string(
"symposion/emails/%s/subject.txt" % kind, ctx
).strip(),
)
message_html = render_to_string(
"symposion/emails/%s/message.html" % kind, ctx
)
message_plaintext = strip_tags(message_html)
from_email = settings.DEFAULT_FROM_EMAIL
email = EmailMultiAlternatives(
subject, message_plaintext, from_email, to, cc=cc
)
email.attach_alternative(message_html, "text/html")
email.send()
示例10: send_email
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_FROM_EMAIL [as 別名]
def send_email(self, user, place):
config = SiteConfiguration.get_solo()
email_template_subject = get_template('email/new_authorization_subject.txt')
email_template_text = get_template('email/new_authorization.txt')
email_template_html = get_template('email/new_authorization.html')
# TODO : Unsubscribe link in the email
email_context = {
'site_name': config.site_name,
'ENV': settings.ENVIRONMENT,
'subject_prefix': settings.EMAIL_SUBJECT_PREFIX_FULL,
'user': user,
'place': place,
}
# TODO : send mail only if the user chose to receive this type
send_mail(
''.join(email_template_subject.render(email_context).splitlines()),
email_template_text.render(email_context),
settings.DEFAULT_FROM_EMAIL,
recipient_list=[user.email],
html_message=email_template_html.render(email_context),
fail_silently=False,
)
示例11: test_mass_html_mail
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_FROM_EMAIL [as 別名]
def test_mass_html_mail(self):
test_data = list()
faker = Faker()
for i in range(random.randint(3, 7)):
test_data.append((
faker.sentence(),
faker.word(), "<strong>{}</strong>".format(faker.word()),
"test@ps", [],
))
for j in range(random.randint(1, 3)):
test_data[i][4].append(faker.email())
result = send_mass_html_mail(test_data)
self.assertEqual(result, len(test_data))
self.assertEqual(len(mail.outbox), len(test_data))
for i in range(len(test_data)):
for j in range(len(test_data[i][4])):
self.assertEqual(mail.outbox[i].subject, test_data[i][0])
self.assertEqual(mail.outbox[i].from_email, settings.DEFAULT_FROM_EMAIL)
self.assertEqual(mail.outbox[i].to, test_data[i][4])
示例12: send_mass_html_mail
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_FROM_EMAIL [as 別名]
def send_mass_html_mail(datatuple, fail_silently=False, user=None, password=None,
connection=None):
"""
Given a datatuple of (subject, text_content, html_content, from_email,
recipient_list), sends each message to each recipient list. Returns the
number of emails sent.
If from_email is None, the DEFAULT_FROM_EMAIL setting is used.
If auth_user and auth_password are set, they're used to log in.
If auth_user is None, the EMAIL_HOST_USER setting is used.
If auth_password is None, the EMAIL_HOST_PASSWORD setting is used.
"""
connection = connection or get_connection(
username=user, password=password, fail_silently=fail_silently)
messages = []
default_from = settings.DEFAULT_FROM_EMAIL
for subject, text, html, from_email, recipients in datatuple:
message = EmailMultiAlternatives(
subject, text, default_from, recipients,
headers={'Reply-To': 'Pasporta Servo <saluton@pasportaservo.org>'})
message.attach_alternative(html, 'text/html')
messages.append(message)
return connection.send_messages(messages) or 0
示例13: handle
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_FROM_EMAIL [as 別名]
def handle(self, *args, **options):
accounts = StripeAccount.objects.all()
for account in accounts:
try:
stripe_account = stripe.Account.retrieve(account.account_id)
if account.verification != stripe_account.verification:
account.verification = json.dumps(
stripe_account.verification)
account.save()
if stripe_account.verification.fields_needed:
email_context = (
{'expiration': stripe_account.verification.due_by})
message = email_template.render(email_context)
send_mail(
'[codesy] Account validation needed',
message,
settings.DEFAULT_FROM_EMAIL,
[account.user.email]
)
except:
e = sys.exc_info()[0]
logger.error("Error during check_validation: %s" % e)
示例14: notify_matching_askers
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_FROM_EMAIL [as 別名]
def notify_matching_askers(sender, instance, **kwargs):
email_template = get_template('../templates/email/ask_met.html')
unnotified_asks = Bid.objects.filter(
url=instance.url, ask_match_sent=None).exclude(ask__lte=0)
for bid in unnotified_asks:
if bid.ask_met():
email_context = {'ask': bid.ask, 'url': bid.url}
subject = (
"[codesy] There's $%(ask)d waiting for you!" % email_context
)
message = email_template.render(email_context)
send_mail(
subject,
message,
settings.DEFAULT_FROM_EMAIL,
[bid.user.email]
)
# use .update to avoid recursive signal processing
Bid.objects.filter(id=bid.id).update(ask_match_sent=timezone.now())
示例15: password_changed_signal
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_FROM_EMAIL [as 別名]
def password_changed_signal(sender, instance, **kwargs):
"""
Regenerate token on password change
:param sender:
:param instance:
:param kwargs:
:return:
"""
mail_subect = _('Nextcloud Appstore password changed')
mail_message = _('Your Appstore password has changed. '
'Contact support if this wasn\'t you.')
try:
user = get_user_model().objects.get(pk=instance.pk)
if user.password != instance.password:
update_token(user.username)
send_mail(
mail_subect,
mail_message,
settings.DEFAULT_FROM_EMAIL,
[user.email],
False)
except User.DoesNotExist:
pass