def send_to_customer(self, sender, customer, order=None, extra_message=None, subject=None): #pylint: disable-msg=R0913 output = self.render(customer, order, extra_message) subject = subject if subject else self.tokenize(self.subject, customer, order) mail = UserMail(sender) mail.send(customer.email, subject, output) Status.add(customer, self, Status.find_event(customer.campaign.company.enterprise_id, self, 'SENT'), 'Sent %s (%s)' % (self.name, subject)) return True
def test_send_with_attachment(self): ent = Enterprise.find_all()[0] comp = Company.find_all(ent.enterprise_id)[0] mail = UserMail(comp.default_campaign) rand_subj = random.random() mail.send('*****@*****.**', 'test %s' % rand_subj, 'This is generated by pvscore/tests/functional/test_mail:test_send_with_attachment', 'README.md')
def send_admin_post_sale_comm(self, order): mail_info = self.get_email_info() if mail_info and mail_info.email: mail = UserMail(self) mail.send(mail_info.email, "New Order", """ New Order for {entname}<br/><br/><hr/><br/><br/> {summary} """.format(summary=order.summary, entname=order.campaign.company.name)) return True
def test_send_with_bad_attachment(self): ent = Enterprise.find_all()[0] comp = Company.find_all(ent.enterprise_id)[0] mail = UserMail(comp.default_campaign) rand_subj = random.random() excepted = False try: mail.send('*****@*****.**', 'test %s' % rand_subj, 'this should never make it. bogus attachment.', 'BOGUS.txt') except IOError as ioe: excepted = True assert excepted
def contact(self): camp = self.request.ctx.campaign message = self.request.POST.get('message') email = self.request.POST.get('email') msg = "%s %s<br>(%s)<br><br>%s<br><br>%s" % (self.request.POST.get('fname'), self.request.POST.get('lname'), email, self.request.POST.get('phone'), message) if util.nvl(self.request.POST.get('save')): cust = Customer.find(email, camp) if not cust: cust = Customer() cust.campaign = camp cust.bind(self.request.POST) cust.phone = cust.phone[:20] if cust.phone else None # prevents people from putting in "904-716-7487 (mobile)" and it barfs cust.save() Status.add(cust, cust, Status.find_event(self.enterprise_id, cust, 'NOTE'), 'NOTE FROM CUSTOMER\n%s' % message) email_info = camp.get_email_info() mail = UserMail(camp) mail.send(email_info.email, 'SITE CONTACT FORM %s' % self.request.host, msg) return self.find_redirect()