Пример #1
0
def send_forgot_password_email(user, request):
    '''
    Send forget password email
    '''
    token = generate_valid_string()
    password = generate_password()
    user.set_password(password)
    hash_password = user.password
    url = u"http://"+ request.META["HTTP_HOST"]+'/activated_password/%s/' % token
    html_content = loader.render_to_string(EMAIL_FORGET_PASSWORD,
        {
            'real_name': (user.get_profile().real_name if user.get_profile().real_name else user.get_profile().cp_name),
            'new_pwd': password,
            'url': url,
            'admin_email': settings.ADMIN_EMAIL
        }
    )
    text_content = strip_tags(html_content)
    try:
        result = send_html_mail(
            u'密码重置-吴江招聘网',
            text_content,
            html_content,
            settings.EMAIL_FROM_USER,
            [user.email,]
        )
        if result != 1:
            raise Exception('Send email failed.');
    except Exception, e:
        print 'Send email failed-> %s' % e
        return False
Пример #2
0
def send_forgot_password_email(user, request):
    '''
    Send forget password email
    '''
    token = generate_valid_string()
    password = generate_password()
    user.set_password(password)
    hash_password = user.password
    url = u"http://" + request.META[
        "HTTP_HOST"] + '/activated_password/%s/' % token
    html_content = loader.render_to_string(
        EMAIL_FORGET_PASSWORD, {
            'real_name':
            (user.get_profile().real_name
             if user.get_profile().real_name else user.get_profile().cp_name),
            'new_pwd':
            password,
            'url':
            url,
            'admin_email':
            settings.ADMIN_EMAIL
        })
    text_content = strip_tags(html_content)
    try:
        result = send_html_mail(u'密码重置-吴江招聘网', text_content, html_content,
                                settings.EMAIL_FROM_USER, [
                                    user.email,
                                ])
        if result != 1:
            raise Exception('Send email failed.')
    except Exception, e:
        print 'Send email failed-> %s' % e
        return False
Пример #3
0
def send_apply_email(request, login_user, job_id):
    """
    发送申请工作邮件
    """
    job = get_object_or_404(models.Job, pk=job_id)
    resume = models.Resume.objects.get(user_profile=login_user.get_profile())
    resume_kwargs = prepare_resume_parameters(request, resume.id)
    html_content = loader.render_to_string(RESUME_VIEW_PAGE, resume_kwargs)
    text_content = strip_tags(html_content)
    try:
        result = send_html_mail(
            u'(wj-zpw.com)申请贵公司%s (%s)' % (job.name, job.location),
            text_content, html_content,
            (u'吴江招聘网-' + login_user.get_profile().real_name), [
                job.company.user.email,
            ])
        if result != 1:
            raise Exception('Send email failed.')
    except Exception, e:
        raise Exception('Send email failed-> %s' % e)
Пример #4
0
def send_apply_email(request, login_user, job_id):
    """
    发送申请工作邮件
    """
    job = get_object_or_404(models.Job, pk=job_id)
    resume = models.Resume.objects.get(user_profile=login_user.get_profile())
    resume_kwargs = prepare_resume_parameters(request, resume.id);
    html_content = loader.render_to_string(RESUME_VIEW_PAGE, resume_kwargs)
    text_content = strip_tags(html_content)
    try:
        result = send_html_mail(
            u'(wj-zpw.com)申请贵公司%s (%s)' % (job.name, job.location),
            text_content,
            html_content,
            (u'吴江招聘网-' + login_user.get_profile().real_name),
            [job.company.user.email,]
        )
        if result != 1:
            raise Exception('Send email failed.');
    except Exception, e:
        raise Exception('Send email failed-> %s' % e)