本文整理汇总了Python中templated_email.send_templated_mail函数的典型用法代码示例。如果您正苦于以下问题:Python send_templated_mail函数的具体用法?Python send_templated_mail怎么用?Python send_templated_mail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send_templated_mail函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:27,代码来源:test_staff.py
示例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
}, )
开发者ID:onaio,项目名称:onadata,代码行数:26,代码来源:mailer.py
示例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
)
开发者ID:localastronaut,项目名称:perdiem-django,代码行数:7,代码来源:messages.py
示例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()
开发者ID:kalaiR,项目名称:evewat,代码行数:30,代码来源:workers.py
示例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
开发者ID:eteks,项目名称:Adjod,代码行数:32,代码来源:loggers.py
示例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
开发者ID:eddowding,项目名称:signmeup,代码行数:34,代码来源:models.py
示例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!")
开发者ID:Participe,项目名称:MVP,代码行数:35,代码来源:views.py
示例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')
开发者ID:Acidburn0zzz,项目名称:difio,代码行数:33,代码来源:views.py
示例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
开发者ID:mirumee,项目名称:saleor,代码行数:28,代码来源:test_staff.py
示例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')
开发者ID:OmniRose,项目名称:omnirose-website,代码行数:34,代码来源:views.py
示例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,
},
)
开发者ID:tylerwinslow,项目名称:DocMan,代码行数:33,代码来源:models.py
示例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),)
开发者ID:omarinho,项目名称:dirPlace,代码行数:25,代码来源:views.py
示例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
开发者ID:kalaiR,项目名称:evewat,代码行数:33,代码来源:views.py
示例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))
开发者ID:vvnab,项目名称:shinuk,代码行数:25,代码来源:views.py
示例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)
开发者ID:tylerwinslow,项目名称:DocMan,代码行数:25,代码来源:send_checkmail.py
示例16: send_mail_task
def send_mail_task(content, from_mail, to_mails, template):
send_templated_mail(
template_name=template,
from_email=from_mail,
recipient_list=to_mails,
context=content
)
开发者ID:yozel,项目名称:alskdjBlog,代码行数:7,代码来源:tasks.py
示例17: contact
def contact(request):
"""
Contact us
"""
success_msg = None
if request.POST:
contact = ContactForm()
contact.name = request.POST.get('name', '')
contact.email = request.POST.get('email', '')
contact.mobile = request.POST.get('phone', '')
contact.message = request.POST.get('message', '')
contact.save()
try:
send_templated_mail(
template_name='contact',
from_email='[email protected]',
recipient_list=[request.POST.get('email')],
context={
'username':request.POST.get('name', 'Guest')
},
)
except:
email = None
success_msg = "Your request successfully sent to Admin. We will revert back you soon"
return render_to_response('contact_us.html',{'success_msg':success_msg}, context_instance=RequestContext(request))
开发者ID:armsmani,项目名称:maidinfo,代码行数:25,代码来源:views.py
示例18: order
def order(request):
if request.is_ajax() and request.method == 'POST':
form = OrderForm(request.POST or None)
if form.is_valid():
order = form.save()
info = json.loads(order.summary_info)
trip = get_object_or_None(Trips, id=order.cont_id)
moneta_form = MonetaForm(
account_id=MONETA_ACCOUNT_ID,
transaction_id=order.id,
amount='100.00',
use_signature=True,
integrity_check_code='tripper',
description=u'Оплата экскурсии: %s' % trip.name
)
send_templated_mail(
template_name='order',
from_email=DEFAULT_FROM_EMAIL,
recipient_list=[order.email],
context={
'fullname':order.fullname,
'info': json.loads(order.summary_info) if order.summary_info else {},
'trip': trip
},
)
data = {
'success': True,
'form': moneta_form.as_p()
}
return HttpResponse(json.dumps(data), mimetype="application/json")
raise Http404
开发者ID:zaebee,项目名称:yasenput,代码行数:31,代码来源:views.py
示例19: irun
def irun(self):
# Recover current state to go on where we ended last time,
# or start from the beginning.
if Setting.notify_bans and settings.VBM_NOTIFICATIONS_EMAIL:
ban_submissions = BanSubmission.objects.filter(launched_at__isnull=False)
if Setting.notify_bans_task_status is not None:
ban_submissions = ban_submissions.filter(pk__gt=Setting.notify_bans_task_status)
# Prepare data.
submissions_log = [{
'id': ban_submission.id,
'launched_at': ban_submission.launched_at,
'user': ban_submission.user.human_name,
'ban_type': ban_submission.human_ban_type_name,
'expression': ban_submission.expression,
'target_type': ban_submission.target.human_class_name,
'target': ban_submission.target.human_name,
'items': ban_submission.items.all(),
} for ban_submission in ban_submissions.iterator()]
if len(submissions_log) > 0:
# Send e-mail.
send_templated_mail(
template_name='varnish-bans-manager/core/bans/submissions',
from_email=settings.DEFAULT_FROM_EMAIL,
recipient_list=[settings.VBM_NOTIFICATIONS_EMAIL],
bcc=settings.DEFAULT_BCC_EMAILS,
context={
'base_url': settings.VBM_BASE_URL,
'submissions_log': submissions_log,
},
)
# Store last seen id to keep track of our position.
Setting.notify_bans_task_status = submissions_log[-1]['id']
开发者ID:BillTheBest,项目名称:varnish-bans-manager,代码行数:32,代码来源:bans.py
示例20: form_valid
def form_valid(self, form):
user = form.save()
user.is_active = True
user.save()
registration = Registration.objects.create(user=user)
# user = User.objects.get(registration__uuid=uuid, type='register')
# user.is_active = True
# user.save()
# user.registration.delete()
#
messages.info(self.request, 'Registration successfull')
send_templated_mail(
template_name='registration',
# substitute your e-mail adress
from_email='[email protected]',
recipient_list=[form.cleaned_data['email'],],
context={
'url_name': 'activation',
'url_param': 'key',
'registration': registration,
'current_site': Site.objects.get_current(),
'base_url': settings.SITE_URL,
},
)
return super(RegisterView, self).form_valid(form)
开发者ID:ForumDev,项目名称:forumdev-user,代码行数:26,代码来源:views.py
注:本文中的templated_email.send_templated_mail函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论