本文整理汇总了Python中wagtail.wagtailadmin.utils.send_mail函数的典型用法代码示例。如果您正苦于以下问题:Python send_mail函数的具体用法?Python send_mail怎么用?Python send_mail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send_mail函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_form_submission
def process_form_submission(self, form):
super(AbstractEmailForm, self).process_form_submission(form)
if self.to_address:
addresses = [x.strip() for x in self.to_address.split(',')]
content = '\n'.join([x[1].label + ': ' + text_type(form.data.get(x[0])) for x in form.fields.items()])
send_mail(self.subject, content, addresses, self.from_address,)
示例2: test_send_default_from_email
def test_send_default_from_email(self):
send_mail("Test subject", "Test content", ["[email protected]"])
# Check that the email was sent
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(mail.outbox[0].subject, "Test subject")
self.assertEqual(mail.outbox[0].body, "Test content")
self.assertEqual(mail.outbox[0].to, ["[email protected]"])
self.assertEqual(mail.outbox[0].from_email, "[email protected]")
示例3: test_send_fallback_to_default_from_email_setting
def test_send_fallback_to_default_from_email_setting(self):
send_mail("Test subject", "Test content", ["[email protected]"])
# Check that the email was sent
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(mail.outbox[0].subject, "Test subject")
self.assertEqual(mail.outbox[0].body, "Test content")
self.assertEqual(mail.outbox[0].to, ["[email protected]"])
self.assertEqual(mail.outbox[0].from_email, "[email protected]")
示例4: test_send_email
def test_send_email(self):
send_mail("Test subject", "Test content", ["[email protected]"], "[email protected]")
# Check that the email was sent
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(mail.outbox[0].subject, "Test subject")
self.assertEqual(mail.outbox[0].body, "Test content")
self.assertEqual(mail.outbox[0].to, ["[email protected]"])
self.assertEqual(mail.outbox[0].from_email, "[email protected]")
示例5: process_form_submission
def process_form_submission(self, form):
super(AbstractEmailForm, self).process_form_submission(form)
if self.to_address:
content = ''
for x in form.fields.items():
if not isinstance(x[1], SweetCaptchaField): # exclude SweetCaptchaField from notification
content += '\n' + x[1].label + ': ' + text_type(form.data.get(x[0]))
send_mail(self.subject, content, [self.to_address], self.from_address,)
示例6: send_mail
def send_mail(self, form):
addresses = [x.strip() for x in self.to_address.split(',')]
content = []
for field in form:
value = field.value()
if isinstance(value, list):
value = ', '.join(value)
content.append('{}: {}'.format(field.label, value))
content = '\n'.join(content)
send_mail(self.subject, content, addresses, self.from_address,)
示例7: process_form_submission
def process_form_submission(self, form):
self.get_submission_class().objects.create(
form_data=json.dumps(form.cleaned_data, cls=DjangoJSONEncoder),
page=self, user=form.user
)
if self.to_address:
addresses = [x.strip() for x in self.to_address.split(',')]
content = '\n'.join([x[1].label + ': ' + text_type(form.data.get(x[0])) for x in form.fields.items()])
send_mail(self.subject, content, addresses, self.from_address,)
示例8: process_form_submission
def process_form_submission(self, form):
super(AbstractEmailForm, self).process_form_submission(form)
if self.to_address:
content = '\n'.join([x[1].label + ': ' + text_type(form.data.get(x[0])) for x in form.fields.items()])
if 'your-name' in form.data and 'your-email' in form.data:
subject = u'{}: {} <{}>'.format(self.subject, form.data['your-name'], form.data['your-email'])
else:
subject = self.subject
send_mail(subject, content, [self.to_address], self.from_address,)
示例9: serve
def serve(self, request, *args, **kwargs):
if request.is_ajax() and request.method == "POST":
form = GoogleAdGrantApplicationForm(request.POST)
if form.is_valid():
form.save()
if self.to_address:
subject = "{} form submission".format(self.title)
content = '\n'.join([x[1].label + ': ' + str(form.data.get(x[0])) for x in form.fields.items()])
send_mail(subject, content, [self.to_address],)
return render(
request,
'torchbox/includes/ad_grant_application_landing.html',
{'self': self, 'form': form}
)
else:
return render(
request,
'torchbox/includes/ad_grant_application_form.html',
{'self': self, 'form': form}
)
else:
return super(GoogleAdGrantsPage, self).serve(request)
示例10: process_form_submission
def process_form_submission(self, form):
super(AbstractEmailForm, self).process_form_submission(form)
if self.to_address:
content = '\n'.join([x[1].label + ': ' + form.data.get(x[0]) for x in form.fields.items()])
send_mail(self.subject, content, [self.to_address], self.from_address,)
示例11: send_mail
def send_mail(self, form):
addresses = [x.strip() for x in self.to_address.split(',')]
content = '\n'.join([x[1].label + ': ' + text_type(form.data.get(x[0])) for x in form.fields.items()])
send_mail(self.subject, content, addresses, self.from_address,)