本文整理汇总了Python中templated_email.send_templated_mail函数的典型用法代码示例。如果您正苦于以下问题:Python send_templated_mail函数的具体用法?Python send_templated_mail怎么用?Python send_templated_mail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send_templated_mail函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_send_set_password_email
def test_send_set_password_email(staff_user, site_settings):
site = site_settings.site
uid = urlsafe_base64_encode(force_bytes(staff_user.pk)).decode()
token = default_token_generator.make_token(staff_user)
logo_url = build_absolute_uri(static('images/logo-light.svg'))
password_set_url = build_absolute_uri(
reverse(
'account:reset-password-confirm',
kwargs={'token': token, 'uidb64': uid}))
ctx = {
'logo_url': logo_url,
'password_set_url': password_set_url,
'site_name': site.name}
send_templated_mail(
template_name='dashboard/staff/set_password',
from_email=DEFAULT_FROM_EMAIL,
recipient_list=[staff_user.email],
context=ctx)
assert len(mail.outbox) == 1
generated_link = reverse(
'account:reset-password-confirm',
kwargs={
'uidb64': uid,
'token': token})
absolute_generated_link = build_absolute_uri(generated_link)
sended_message = mail.outbox[0].body
assert absolute_generated_link in sended_message
示例2: handle
def handle(self, *args, **options):
message = options.get('message')
verbosity = options.get('verbosity')
get_template('templated_email/notice.email')
if not message:
raise CommandError(_('message must be included in options'))
# get all users
users = User.objects.all()
for user in users:
name = user.get_full_name()
if not name or len(name) == 0:
name = user.email
if verbosity:
self.stdout.write(_(
'Emailing name: %(name)s, email: %(email)s')
% {'name': name, 'email': user.email})
# send each email separately so users cannot see eachother
send_templated_mail(
template_name='notice',
from_email='[email protected]',
recipient_list=[user.email],
context={
'username': user.username,
'full_name': name,
'message': message
}, )
示例3: send_to_email
def send_to_email(self, email, context={}):
send_templated_mail(
template_name=self.get_template_name(),
from_email=settings.DEFAULT_FROM_EMAIL,
recipient_list=[email],
context=context
)
示例4: create_tasks
def create_tasks(self):
print "create_tasks"
now = helper.get_now()
user=User()
sitebanner=SiteBanner.objects.all()
for sitebanners in sitebanner:
user_id=sitebanners.user_id
print user_id
user=User.objects.get(id=user_id)
print user
email=user.email
print email
name=user.username
print name
result=sitebanners.enddate
print "result", result
if result:
subject="Your " + " Your banner will be removed from today onwards"
sitebanners.admin_status = False
send_templated_mail(
template_name = 'welcome',
subject = "subject",
from_email = '[email protected]',
recipient_list = [email],
context = {'name':name},
)
print "mail send"
sitebanners.save()
示例5: emit
def emit(self, record):
try:
from logs.models import ErrorLog
logEntry =ErrorLog()
logEntry.level = record.levelname
logEntry.error_msg = record.getMessage(), record.exc_info
logEntry.ip_address = globals.ip
# print "logEntry.ip_address", logEntry.ip_address
logEntry.page = record.args, record.lineno, record.pathname
logEntry.datetime = datetime.datetime.now()
logEntry.user = record.request.user
logEntry.admin_status = 'open'
logEntry.save()
except:
pass
try:
if record.levelname == 'ERROR':
send_templated_mail(
template_name='error',
from_email=settings.DEFAULT_FROM_EMAIL,
recipient_list=[],
context={
'errorlevel': record.levelname,
'error_msg': [record.getMessage(), record.exc_info],
'error_ip': globals.ip,
'error_user': record.request.user,
'error_line' : [record.lineno, record.pathname],
},
)
except:
pass
示例6: save
def save(self, *args, **kwargs):
# New model
NEW = False
if not self.pk:
NEW = True
self.token = self.generate_token()
send_templated_mail(
template_name='new_signup',
from_email=settings.DEFAULT_FROM_EMAIL,
recipient_list=[self.email],
context={
'token': self.token,
'name': self.name,
'email': self.email,
'postcode': self.postcode,
}
)
m = super(SignUp, self).save(*args, **kwargs)
if NEW:
# For now, just update the whole coultry. More to follow.
area, created = LocalInfo.objects.get_or_create(type='country', name='UK')
for key in self._fields:
if key in self.COLLECT:
if bool(getattr(self, key)):
count = area.info.get(key, 0) + 1
area.info[key] = count
else:
area.info[key] = area.info.get(key, 0)
area.save()
return m
示例7: ajax_participation_remove
def ajax_participation_remove(request, challenge_id):
if request.is_ajax():
ctx = {}
participation_id = request.POST.get("participation_id", "")
value = request.POST.get("action_id", "")
text = request.POST.get("text", "")
try:
participation = Participation.objects.get(pk=participation_id)
except:
return HttpResponse("An error has been encountered")
ctx.update({
"user": participation.user,
"challenge": participation.challenge,
"participation": participation, })
if value == PARTICIPATION_REMOVE_MODE.REMOVE_APPLICATION:
participation.status = PARTICIPATION_STATE.CANCELLED_BY_ADMIN
template_name = "challenge_participation_removed"
elif value == PARTICIPATION_REMOVE_MODE.REJECT_APPLICATION:
participation.status = PARTICIPATION_STATE.CONFIRMATION_DENIED
template_name = "challenge_participation_rejected"
participation.cancellation_text = text
participation.date_cancelled = datetime.now()
participation.save()
send_templated_mail(
template_name=template_name,
from_email="[email protected]",
recipient_list=[participation.user.email, ],
context=ctx, )
return HttpResponse()
return HttpResponse("An error has been encountered!")
示例8: ajax_invite_friends
def ajax_invite_friends(request):
"""
Send email invitation to friends
"""
# we've got a POST request which means user wants to invite friends
if request.POST:
try:
recipients = request.POST.get('recipients', "")
#todo: schedule batch action to offload main webserver
for r in recipients.split("\n"):
for addr in r.split(" "):
for email in addr.split(","):
try:
email = email.strip()
if email.find("@") == -1:
continue
send_templated_mail(
template_name='invite_friends',
from_email="Difio <%s>" % settings.DEFAULT_FROM_EMAIL,
recipient_list=[email],
context={
'username':request.user.username,
'full_name':request.user.get_full_name(),
},
)
except:
continue
except:
pass
return HttpResponse("SUCCESS", mimetype='text/plain')
示例9: test_send_set_password_email
def test_send_set_password_email(staff_user, site_settings):
site = site_settings.site
uid = urlsafe_base64_encode(force_bytes(staff_user.pk))
token = default_token_generator.make_token(staff_user)
logo_url = build_absolute_uri(static("images/logo-light.svg"))
password_set_url = build_absolute_uri(
reverse(
"account:reset-password-confirm", kwargs={"token": token, "uidb64": uid}
)
)
ctx = {
"logo_url": logo_url,
"password_set_url": password_set_url,
"site_name": site.name,
}
send_templated_mail(
template_name="dashboard/staff/set_password",
from_email=DEFAULT_FROM_EMAIL,
recipient_list=[staff_user.email],
context=ctx,
)
assert len(mail.outbox) == 1
generated_link = reverse(
"account:reset-password-confirm", kwargs={"uidb64": uid, "token": token}
)
absolute_generated_link = build_absolute_uri(generated_link)
sended_message = mail.outbox[0].body
assert absolute_generated_link in sended_message
示例10: form_valid
def form_valid(self, form):
obj = form.save(commit=False)
password = User.objects.make_random_password()
obj.set_password(password)
obj.is_active = True
obj.save()
# Now log in this user
user = authenticate(email=obj.email, password=password)
if user is not None:
login(self.request, user)
else:
raise Exception("Could not auth recently created user")
# send password in email
send_templated_mail(
template_name='accounts/new_user_email',
from_email=settings.DEFAULT_FROM_EMAIL,
recipient_list=[user.email],
context = {
'user': user,
'password': password,
'BASE_URL': settings.BASE_URL
}
)
# where to next? If we have a next go there, otherwise home
next_url = self.request.POST.get('next')
if next_url:
return redirect(next_url)
else:
return redirect('home')
示例11: save
def save(self, force_insert=False, force_update=False, *args, **kwargs):
is_new = self.id is None
super(Project, self).save(*args, **kwargs)
if is_new:
Document.objects.create(project=self, title='Act Notes', internal=True)
Document.objects.create(project=self, title='SRTO', internal=True)
if self. financing_cash > 0:
Document.objects.create(project=self, title='Cash')
if self.financing_hloc > 0:
Document.objects.create(project=self, title='HELOC')
if self.financing_401k > 0:
Document.objects.create(project=self, title='401K')
if self.financing_pension > 0:
Document.objects.create(project=self, title='Pension')
if self.financing_ira > 0:
Document.objects.create(project=self, title='IRA')
if self.financing_stocksbonds > 0:
Document.objects.create(project=self, title='Stocks and Bonds')
if not User.objects.filter(username=self.email).count():
user = User.objects.create_user(self.email, self.email, 'erF213')
user.last_name = self.last_name
user.first_name = self.first_name
user.save()
self.customers_user = user
self.save()
send_templated_mail(
template_name='new_app',
from_email='[email protected]',
recipient_list=[self.email],
context={
'project': self,
},
)
示例12: contact
def contact(request):
EMAIL_CUSTOMER_ATTENDANT = getattr(settings, 'EMAIL_CUSTOMER_ATTENDANT', '[email protected]')
DEFAULT_FROM_EMAIL = getattr(settings, 'DEFAULT_FROM_EMAIL', '[email protected]')
DOMAINURL = getattr(settings, 'DOMAINURL', 'http://dirplace.com/')
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
message = 'Please reply to: ' + cd['email'] + '\n\n\n'
message = message + cd['description']
send_templated_mail(
template_name='contact-notification',
from_email=DEFAULT_FROM_EMAIL,
recipient_list=[EMAIL_CUSTOMER_ATTENDANT],
context={
'message':message,
},
)
return redirect('/dirplace/contact_thanks/')
else:
form = ContactForm()
c = {
'form': form
}
return render_to_response ('dirplace/contact-us.html', c, context_instance = RequestContext(request),)
示例13: upload_banner
def upload_banner(request):
if request.POST.get('price',False):
uploadbanner=SiteBanner()
uploadbanner.price=request.POST.get('price',request.COOKIES.get('price'))
uploadbanner.position=request.POST.get('position',request.COOKIES.get('position'))
uploadbanner.pageurl=request.POST.get('pageurl',request.COOKIES.get('pageurl'))
uploadbanner.banner=request.FILES.get('banner',request.COOKIES.get('banner'))
uploadbanner.link=request.POST['link']
uploadbanner.save()
send_templated_mail(
template_name = 'banner',
subject = 'Uplaod Banner',
from_email = '[email protected]',
recipient_list = [request.user.email ],
context={
'user': request.user,
},
)
response=HttpResponseRedirect("/payment/")
response.set_cookie( 'price', uploadbanner.price )
response.set_cookie( 'position', uploadbanner.position )
response.set_cookie( 'banner', uploadbanner.banner )
response.set_cookie( 'pageurl', uploadbanner.pageurl )
#field9 is payu success variable
# this if condition for after success of payment
elif 'field9' in request.POST:
message="Your data succesfully uploaded"
response = render_to_response("uploadbanner.html",{'message':message},context_instance=RequestContext(request))
else:
message="Something went to wrong"
response = render_to_response("uploadbanner.html",{'message':message},context_instance=RequestContext(request))
return response
示例14: email
def email(request):
users = User.objects.all()
if request.method == 'POST':
emailUsers = User.objects.filter(id__in = request.POST.getlist('emailUsers'))
for i in emailUsers:
logger.info('Send email to - {0}'.format(i.email))
try:
template = request.POST.get('emailUrl')
send_templated_mail(
template_name = template,
from_email = u'Магазин ShinUK <[email protected]>',
recipient_list = [i.email],
context = {
'text': request.POST.get('emailText', ''),
'user': i
}
)
logger.info('Ok sended email to - {0}'.format(i.email))
except:
logger.info('Errror!!! send email to - {0}'.format(i.email))
messages.error(request, u'Ошибка при отправке письма с уведомлением!')
return redirect('/ladmin/email/')
else:
pass
return render_to_response('ladmin/email.html', locals(), context_instance = RequestContext(request))
示例15: handle
def handle(self, *args, **options):
projects = Project.objects.all()
number_emails = 0
task_type = TaskType.objects.get(title="phone")
for project in projects:
delta = project.create_date.replace(tzinfo=None) - datetime.now()
if delta.days == -6 and project.funding_advisor:
number_emails = number_emails + 1
task = Task(title="Day Six in Finance Check Call",
scheduled_date=date.today(),
completion=False,
task_type=task_type,
project=project,
user=project.sales_rep.user)
task.save()
send_templated_mail(
template_name='financeday6',
from_email='[email protected]',
recipient_list=[project.sales_rep.user.email, '[email protected]'],
context={
'project': project,
'task': task
},
)
self.stdout.write('Sent "%s" emails' % number_emails)