本文整理汇总了Python中post_office.mail.send函数的典型用法代码示例。如果您正苦于以下问题:Python send函数的具体用法?Python send怎么用?Python send使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: register_team
def register_team(request,eventId,teamId):
email = request.session.get('saaranguser_email')
try:
user = SaarangUser.objects.get(email=email)
except:
messages.error(request, 'Please login to continue')
return render(request, 'main/login.html', {})
event = get_object_or_404(Event,id=eventId)
team = get_object_or_404(Team,id=teamId)
if EventRegistration.objects.filter(event=event,team=team):
if event.id in EVENT_WITH_OPTIONS:
return HttpResponseRedirect(reverse('band_details',kwargs={'eventId':eventId,'teamId':teamId}))
messages.info(request,'Already registered for the event')
else:
if not event.registration_open :
messages.info(request,'Registration is closed for the event.')
else:
EventRegistration.objects.create(participant=user,team=team,event=event,options='')
mail_list = [member.email for member in team.members.all()]
mail_list.append(email)
mail.send(
mail_list, template='email/main/register_team',
context={'event_name':event.long_name, 'team_name':team.name,},
)
if event.id in EVENT_WITH_OPTIONS:
return HttpResponseRedirect(reverse('band_details',kwargs={'eventId':eventId,'teamId':teamId}))
messages.success(request,'Team registered successfully')
return render(request, 'main/register_response.html')
开发者ID:shahidhk,项目名称:saarang_erp,代码行数:28,代码来源:views.py
示例2: handle
def handle(self, *args, **options):
domain = Site.objects.get_current().domain
end_date_target = timezone.now().date()
end_time_since = (timezone.now() - datetime.timedelta(minutes=10)).time()
end_time_until = timezone.now().time()
for activity in Activity.objects.current_year().approved().done().filter(episode__end_date=end_date_target)\
.exclude(assessment__criterionvalue__criterion__category='P')\
.exclude(primary_club__is_assessed=False)\
.distinct():
# If the activity didn't end within the past ten minutes,
# skip, because another proccess would have sent a
# notification about it.
if not activity.episode_set.filter(episode__end_date=end_date_target,
episode__end_time__gt=end_time_since,
episode__end_time__lte=end_time_until).exists():
continue
email_context = {'activity': activity}
assessor_club = Club.objects.club_assessing_parents(activity.primary_club).first()
if assessor_club.coordinator:
full_url = "https://{}{}".format(domain,
reverse('activities:assess',
args=(activity.pk, 'p')))
email_context['full_url'] = full_url
email_context['assessor_club'] = assessor_club
email_context['assessor'] = assessor_club.coordinator
mail.send([assessor_club.coordinator.email],
template="activity_done_to_assessor",
context=email_context)
self.stdout.write(u'Assigned {0} to {1}. Emailing {1}.'.format(activity.name, assessor_club))
开发者ID:osamak,项目名称:student-portal,代码行数:29,代码来源:notify_for_presidency_assessment.py
示例3: handle
def handle(self, *args, **options):
translation.activate(settings.LANGUAGE_CODE)
event = Event.objects.get(code_name=options['event_code_name'])
event_users = (User.objects.filter(certificate__sessions__event=event) | \
User.objects.filter(certificate__abstracts__event=event)).distinct()
count = 1
self.stdout.write("We got {} users to handle!".format(event_users.count()))
domain = Site.objects.get_current().domain
url = "https://{}{}".format(domain,
reverse('certificates:list_certificates_per_user'))
for user in event_users.iterator():
email_context = {'user': user,
'url': url,
'event': event}
notification_email = event.get_notification_email()
cc = accounts.utils.get_user_cc(user)
mail.send([user.email],
u"بوابة إنجاز <{}>".format(notification_email),
cc=cc,
template="event_certificates",
context=email_context)
self.stdout.write("{:06d}: Sent to {}!".format(count, user.email))
count +=1
if options['sleep_time']:
time.sleep(options['sleep_time'])
开发者ID:osamak,项目名称:student-portal,代码行数:26,代码来源:event_send_certificates.py
示例4: check_account
def check_account(request, email):
# return render(request, 'main/activated.html', {})
try:
user = get_object_or_404(SaarangUser, email=base64.b64decode(email))
if user.activate_status == 0:
user.activate_status = 2
user.save()
messages.success(request, 'Your account has been activated')
messages.info(request, 'Your Saarang ID is '+user.saarang_id)
messages.error(request, 'Check you email for exciting Saarang Goodies !!!')
messages.warning(request, 'Please login to Saarang Website by clicking on the Saarang logo')
last = get_object_or_404(LastCoupon, pk=1)
last_coupon = int(last.coupon_id)
coupon = get_object_or_404(Coupon, pk=last_coupon, sent=False)
coupon_code_link = 'https://www.komparify.com/recharge?couponcode='+coupon.code
mail.send(
[user.email], template='email/main/activate_confirm',
context={'saarang_id':user.saarang_id, 'coupon_code_link': coupon_code_link, }
)
coupon.sent = True
coupon.sent_to = user
coupon.save()
last.coupon_id += 1
last.save()
else:
messages.warning(request, 'Your account has already been activated')
except Exception, e:
raise e
messages.error(request, 'Error')
开发者ID:shahidhk,项目名称:saarang_erp,代码行数:29,代码来源:views.py
示例5: add_report
def add_report(request, guide_pk):
guide = get_object_or_404(GuideProfile, pk=guide_pk)
if not utils.can_edit_guide(request.user, guide):
raise Exception(u"لا تستطيع رفع تقرير")
if request.method == 'POST':
current_year = StudentClubYear.objects.get_current()
instance = Report(guide=guide)
form = ReportForm(request.POST, request.FILES, instance=instance)
if form.is_valid():
report = form.save()
show_report_url = reverse('studentguide:show_report', args=(guide.pk, report.pk))
full_url = request.build_absolute_uri(show_report_url)
if guide.assessor:
email_context = {'assessor': guide.assessor,
'guide': guide,
'full_url': full_url}
mail.send([guide.assessor.email],
template="report_submitted_to_assessor",
context=email_context)
return {"message": "success", "show_url": full_url}
elif request.method == 'GET':
form = ReportForm()
context = {'form': form, 'guide': guide}
return render(request, 'studentguide/edit_report_form.html', context)
开发者ID:osamak,项目名称:student-portal,代码行数:27,代码来源:views.py
示例6: add_request
def add_request(request, guide_pk):
guide = get_object_or_404(GuideProfile, pk=guide_pk,
is_deleted=False)
if request.method == 'POST':
instance = Request(user=request.user, guide=guide)
form = RequestForm(request.POST, instance=instance)
if form.is_valid():
guide_request = form.save()
list_guide_requests_url = reverse('studentguide:list_guide_requests', args=(guide.pk,))
email_full_url = request.build_absolute_uri(list_guide_requests_url)
email_context = {'guide': guide,
'guide_request': guide_request,
'full_url': email_full_url}
mail.send([guide.user.email],
template="guide_request_created_to_guide",
context=email_context)
list_my_requests_url = reverse('studentguide:list_my_requests')
full_url = request.build_absolute_uri(list_my_requests_url)
return {"message": "success", "list_url": full_url}
elif request.method == 'GET':
form = RequestForm()
context = {'form': form, 'guide': guide}
return render(request, 'studentguide/edit_request_form.html', context)
开发者ID:osamak,项目名称:student-portal,代码行数:25,代码来源:views.py
示例7: add_guide
def add_guide(request):
if request.method == 'POST':
current_year = StudentClubYear.objects.get_current()
studentguide_club = clubs.utils.get_club_for_user("Student Guide", request.user)
random_assessor = studentguide_club.members.order_by('?').first()
instance = GuideProfile(user=request.user, year=current_year, assessor=random_assessor)
form = GuideForm(request.POST, request.FILES, instance=instance)
if form.is_valid() and not utils.has_guide_profile(request.user):
guide = form.save()
list_supervised_guides_url = reverse('studentguide:list_supervised_guides')
full_url = request.build_absolute_uri(list_supervised_guides_url)
email_context = {'assessor': random_assessor,
'guide': guide,
'full_url': full_url}
# If there are members to pick from, send an email.
if random_assessor:
mail.send([random_assessor.email],
template="guide_assigned_randomly_to_assessor",
context=email_context)
show_guide_url = reverse('studentguide:show_guide', args=(guide.pk,))
full_url = request.build_absolute_uri(show_guide_url)
return {"message": "success", "show_url": full_url}
elif request.method == 'GET':
form = GuideForm()
context = {'form': form}
return render(request, 'studentguide/edit_guide_form.html', context)
开发者ID:osamak,项目名称:student-portal,代码行数:27,代码来源:views.py
示例8: generate_emails
def generate_emails(self):
# Emails are gona be send to all applicants that have
# interview date and didn't receive an email yet
recipients = [student for student in Student.objects.filter(
has_received_email=False,
has_interview_date=True)]
for student in recipients:
mail.send(
recipients=[student.email],
template=self.template,
context={
'name': student.name,
'applied_course': student.applied_course,
'interview_date': student.interviewslot.teacher_time_slot.date,
'interview_start_time': student.interviewslot.start_time,
'confirm_interview_url': self.confirm_interview_url + student.uuid,
'choose_interview_url': self.choose_interview_url + student.uuid,
})
try:
self.__inc_generated_emails()
student.has_received_email = True
student.save()
except Exception as e:
self.__inc_errors()
student.has_received_email = False
student.save()
print(e)
pass
开发者ID:pgergov,项目名称:InterviewCommunicator,代码行数:29,代码来源:generate_confirm_emails.py
示例9: send_email
def send_email(request, pk):
supervisor = get_object_or_404(Supervisor, pk=pk)
if request.method == 'POST':
form = EmailForm(request.POST)
if form.is_valid():
email_context = {'user': request.user,
'supervisor': supervisor,
'data': form.cleaned_data}
mail.send([request.user.email],
"[email protected]",
template="researchhub_send_email_to_student",
context=email_context)
mail.send([supervisor.user.email],
"[email protected]",
bcc="[email protected]",
template="researchhub_send_email_to_supervisor",
context=email_context,
headers={'Reply-to': request.user.email})
return {"message": "success"}
elif request.method == 'GET':
form = EmailForm()
context = {'form': form,
'supervisor': supervisor}
return render(request, 'researchhub/send_email_form.html', context)
开发者ID:osamak,项目名称:student-portal,代码行数:26,代码来源:views.py
示例10: submit_group
def submit_group(request):
if request.method == 'POST':
group_object = StudyGroup(coordinator=request.user)
form = StudyGroupForm(request.POST, instance=group_object)
if form.is_valid():
new_group = form.save()
group_url = reverse('arshidni:show_group',
args=(new_group.pk,))
group_full_url = request.build_absolute_uri(group_url)
admin_url = reverse('arshidni_admin:index')
admin_full_url = request.build_absolute_uri(admin_url)
arshidni_coordinator = get_arshidni_club_for_user(request.user).coordinator
if arshidni_coordinator:
email_context = {'arshidni_coordinator': arshidni_coordinator,
'group': new_group,
'full_url': group_full_url,
'admin_full_url': admin_full_url}
mail.send([arshidni_coordinator.email],
template="study_group_submitted",
context=email_context)
return HttpResponseRedirect(group_url)
else:
context = {'form': form}
elif request.method == 'GET':
form = StudyGroupForm()
context = {'form': form}
return render(request, 'arshidni/group_edit.html', context)
开发者ID:osamak,项目名称:student-portal,代码行数:28,代码来源:views.py
示例11: user_create
def user_create(request, template_name='vnoiusers/user_create.html'):
form = UserCreateForm()
if request.user.is_authenticated():
messages.warning(request, 'Invalid request')
return HttpResponseRedirect(reverse('main:index'))
if request.POST:
form = UserCreateForm(request.POST)
if form.is_valid():
form.save() # save user to database if form is valid
username = form.cleaned_data['username']
email = form.cleaned_data['email']
salt = hashlib.sha1(str(random.random())).hexdigest()[:8]
activation_key = hashlib.sha1(salt+email).hexdigest()
# Get user by username
user = User.objects.get(username=username)
user.profile.activation_key = activation_key
user.profile.save()
# Send email with activation key
if not DEBUG:
email_subject = 'Đăng ký tài khoản VNOI'
email_body = "Hi %s, chào mừng bạn đã đến với VNOI. Để kích hoạt tài khoản, hãy click vào link: %s/user/confirm/%s" % (username, ROOT_URL, activation_key)
mail.send(email, subject=email_subject, message=email_body, priority="now")
return HttpResponse('Một email đã được gửi đến tài khoản email mà bạn đăng ký. Hãy kiểm tra hòm thư của bạn và làm theo hướng dẫn để kích hoạt tài khoản.')
else:
return HttpResponse('Bạn đã đăng ký thành công. Bạn có thể trở về trang chủ để đăng nhập')
else:
return render(request, template_name,
{'form': form, 'message': form.errors})
else:
return render(request, template_name,
{'form': form, 'message': ''})
开发者ID:chequochuu,项目名称:vnoiwebsite,代码行数:35,代码来源:views.py
示例12: send_html_email_with_dj_template
def send_html_email_with_dj_template(recipients, subject, dj_template,
context={}, sender=None, template=None,
message='', headers=None,
priority=None, backend=''):
"""
Arguments:
- `recipients`:
- `subject`:
- `sender`:
- `template`:
- `context`:
"""
base_context = {
'url_base': get_site_scheme_and_netloc(),
'site_name': SITE_NAME,
'media_url': MEDIA_URL,
'logo_path': LOGO_PATH,
}
context.update(base_context)
t = loader.get_template(dj_template)
html_message = t.render(Context(context))
mail.send(recipients, sender=sender, template=template, context=context,
subject=subject, message=message,
html_message=html_message, headers=headers, priority=priority,
backend=backend)
开发者ID:RaphaelWimmer,项目名称:seahub,代码行数:28,代码来源:mail.py
示例13: contato
def contato(request):
name = request.POST.get('name', '')
parceiro = request.POST.get('parceiro', '')
phone = request.POST.get('phone', '')
email = request.POST.get('email', '')
subject = request.POST.get('subject', '')
message = request.POST.get('message', '')
if name and message and email:
mail.send(
['[email protected]'],
sender=settings.DEFAULT_FROM_EMAIL,
template='contato',
context={'name':name,'subject':subject, 'message':message, 'email':email, 'phone':phone},
)
return redirect('http://cdr-port.net')
elif parceiro and message and email:
mail.send(
['[email protected]'],
sender=settings.DEFAULT_FROM_EMAIL,
template='parceiro',
context={'name':parceiro,'subject':subject, 'message':message, 'email':email, 'phone':phone},
)
return redirect('http://parceiros.cdr-port.net')
else:
return HttpResponse("Preencha todos os campos.")
开发者ID:eluizbr,项目名称:portabilidade,代码行数:30,代码来源:views.py
示例14: email
def email(recipient, context, template_name, sender=None):
if not settings.MANDRILL_API_KEY or settings.MANDRILL_API_KEY == 'None':
return
current_site = Site.objects.get_current()
context['domain'] = current_site.domain
User = django.contrib.auth.get_user_model()
# The recipient list can be a list of User model instances or Email Address string
# Which means you could pass a User model QuerySet as recipient
# If a recipient is User model instance then simple convert to Email Address string
recipient_email_list = []
for rec in recipient:
if isinstance(rec, User):
if rec.first_name and rec.last_name:
recipient_email_list.append('"%s %s" <%s>' % (rec.first_name, rec.last_name, rec.email))
elif rec.first_name:
recipient_email_list.append('"%s" <%s>' % (rec.first_name, rec.email))
else:
recipient_email_list.append('%s' % rec.email)
else:
recipient_email_list.append(rec)
mail.send(
sender=sender or settings.DEFAULT_FROM_EMAIL,
recipients=recipient_email_list,
template=template_name,
context=context,
priority=PRIORITY.now
)
开发者ID:DannyPython,项目名称:oxidizr,代码行数:28,代码来源:utils.py
示例15: user_create
def user_create(request, template_name='vnoiusers/user_create.html'):
form = UserCreateForm()
if request.user.is_authenticated():
messages.warning(request, 'Invalid request')
return HttpResponseRedirect(reverse('main:index'))
if request.POST:
form = UserCreateForm(request.POST)
if form.is_valid():
form.save() # save user to database if form is valid
username = form.cleaned_data['username']
email = form.cleaned_data['email']
salt = hashlib.sha1(str(random.random())).hexdigest()[:8]
activation_key = hashlib.sha1(salt+email).hexdigest()
# Get user by username
user = User.objects.get(username=username)
user.profile.activation_key = activation_key
user.profile.save()
# Send email with activation key
email_subject = 'Vnoiwebsite Account confirmation'
email_body = "Hey %s, thanks for signing up. To activate your account, click this link http://127.0.0.1:8000/user/confirm/%s" % (username, activation_key)
mail.send(email, subject=email_subject, message=email_body, priority="now")
return HttpResponse('You have successfully register a new account. An email will be sent to your email shortly. Please click the confirmation link in the email')
else:
return render(request, template_name,
{'form': form, 'message': form.errors})
else:
return render(request, template_name,
{'form': form, 'message': ''})
开发者ID:QuangCarota,项目名称:vnoiwebsite,代码行数:33,代码来源:views.py
示例16: handle
def handle(self, *args, **options):
# set the locale right, to get the dates represented correctly
translation.activate(settings.LANGUAGE_CODE)
offeneLeistungen = (models.Leistung.objects.
filter(
erstellt__lte=datetime.date.today()-datetime.timedelta(days=7)).
exclude(
status=models.Leistung.ACK).
exclude(
status=models.Leistung.NEG)
)
print offeneLeistungen
kontakte = set([l.aufgabe.kontakt() for l in offeneLeistungen])
print kontakte
for k in kontakte:
mail.send(
[k.email], # to address
template="leistungReminder",
)
call_command('send_queued_mail')
translation.deactivate()
开发者ID:gitter-badger,项目名称:svpb,代码行数:27,代码来源:reminderLeistungen.py
示例17: delete_member
def delete_member(request, team_id, member_id):
team = get_object_or_404(HospiTeam, pk=team_id)
user = get_object_or_404(SaarangUser, pk=member_id)
team.members.remove(user)
mail.send([user.email], template="email/hospi/member_deleted", context={"team": team})
return redirect("hospi_home")
开发者ID:shahidhk,项目名称:saarang_erp,代码行数:7,代码来源:views.py
示例18: handle
def handle(self, *args, **options):
translation.activate(settings.LANGUAGE_CODE)
domain = Site.objects.get_current().domain
end_date_target = timezone.now().date()
end_time_since = (timezone.now() - timedelta(minutes=10)).time()
end_time_until = timezone.now().time()
for episode in Episode.objects.filter(activity__is_approved=True,
requires_report=True,
end_date=end_date_target,
end_time__gt=end_time_since,
end_time__lte=end_time_until)\
.exclude(followupreport__isnull=False,
employeereport__isnull=False):
print episode
email_context = {'episode': episode}
if not episode.employee_report_is_submitted() and \
episode.activity.primary_club.employee:
full_url = "https://{}{}".format(domain,
reverse('media:submit_employee_report',
args=(episode.pk,)))
email_context['full_url'] = full_url
mail.send([episode.activity.primary_club.employee.email],
template="due_report_to_report_submitter",
context=email_context)
if not episode.report_is_submitted():
emails = episode.activity.primary_club.media_representatives.values_list('email', flat=True)
if emails:
full_url = "https://{}{}".format(domain,
reverse('media:submit_report',
args=(episode.pk,)))
email_context['full_url'] = full_url
mail.send(list(emails),
template="due_report_to_report_submitter",
context=email_context)
开发者ID:osamak,项目名称:student-portal,代码行数:35,代码来源:notify_on_due_media_reports.py
示例19: home
def home(request):
if request.method == 'POST':
userform =SaarangUserForm(request.POST)
data=request.POST.copy()
if userform.is_valid():
user = userform.save()
user.saarang_id = auto_id(user.pk)
characters = string.ascii_letters + string.punctuation + string.digits
password = "".join(choice(characters) for x in range(randint(8, 16)))
user.password = password
user.activate_status = 2
user.save()
mail.send(
[user.email], template='email/main/activate_confirm',
context={'saarang_id':user.saarang_id, 'password':user.password}
)
userform = SaarangUserForm()
messages.success(request, data['desk_id'] +' Successfully saved')
else:
userform = SaarangUserForm(request.POST)
else:
userform = SaarangUserForm()
to_return={
'form':userform,
'action': "",
'title': "Add a new User"
}
return render(request, 'user_registration/qms.html', to_return)
开发者ID:shahidhk,项目名称:saarang_erp,代码行数:28,代码来源:views.py
示例20: student_action
def student_action(request):
supervision_request_id = request.POST.get('supervision_request_id')
action = request.POST.get('action')
supervision_request = get_object_or_404(SupervisionRequest.objects.current_year(),
pk=supervision_request_id)
if supervision_request.user != request.user:
raise Exception(u'لست أنت مقدم الطلب!')
if action == 'delete':
if supervision_request.status == 'A':
now = datetime.datetime.now()
supervision_request.status = 'WN'
supervision_request.withdrawal_date = now
to_me_url = reverse('arshidni:supervision_requests_to_me')
full_url = request.build_absolute_uri(to_me_url)
arshidni_coordinator = get_arshidni_club_for_user(request.user).coordinator
if arshidni_coordinator:
email_context = {'full_url': full_url,
'supervision_request': supervision_request}
mail.send([supervision_request.colleague.user.email],
cc=[arshidni_coordinator.email],
template="supervision_request_withdrawn",
context=email_context)
elif supervision_request.status == 'P':
supervision_request.status = 'D'
else: # Just in case
raise Exception(u'حدث خطأ غير معروف.')
supervision_request.save()
else:
raise Exception(u'حدث خطأ غير معروف.')
return {'current_status': supervision_request.status,
'full_current_status': supervision_request.get_status_display()}
开发者ID:osamak,项目名称:student-portal,代码行数:34,代码来源:views.py
注:本文中的post_office.mail.send函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论