Пример #1
0
def sendBug(request):
    if request.user.is_authenticated:
        user = request.user
        email = user.email
        content = request.GET["content"]
        if email:
            subject = "Contact : {}.".format(email)
            message = "Dear Sir/Madam\nemail: {}\ncontent : \n{}\n ".format(email,content)
            from_email = settings.EMAIL_HOST_USER
            to_email = settings.EMAIL_HOST_USER
            send_mail(subject,message,from_email,to_email)
            #send_mail(subject,message,from_email,to_email,fail_silently=False)
            return JsonResponse({})
        else:
              response = JsonResponse({"error" : "Some Error Occured"})
              response.status_code = 403
              return response
    else:
        content = request.GET["content"]
        email = request.GET["email"]
        if email:
            subject = "Contact : {}.".format(email)
            message = "Dear Sir/Madam\n Email: {}\n content : \n {}\n".format(email,content)
            from_email = settings.EMAIL_HOST_USER
            to_email = email
            send_mail(subject,message,from_email,to_email)
            return JsonResponse({})
        else:
            response = JsonResponse({"error" : "Some Error Occured"})
            response.status_code = 403
            return response
Пример #2
0
def sendActivationEmail(activation_key,email_target):
        html_message = loader.render_to_string(
            'user/activation_email.html',
            {
                'message': 'Dear Sir/Madam\nPlease click the link below to verify your account',
                'link' : activation_key,
            }
        )
        text_content = 'Text'


        subject = "You have received a notificaion from {}.".format("Notice Project")
        from_email = settings.EMAIL_HOST_USER
        to_email = email_target
        send_mail(subject,html_message,from_email,to_email,html=True)
Пример #3
0
def send_notification(request):
    if request.user.is_authenticated and (request.user.profile.type == 2 or request.user.profile.type == 1) :
        user = request.user
        project_id = request.GET["id"]
        project = Project.objects.all().get(pk=project_id)
        if project_id:
            subject = "You have received a notificaion from {}.".format("Notice Project")
            message = "Dear Sir/Madam\n I am writing this email to inform you that I am interested in this project\n\n Project Name : {} \n Email: {}\n".format(project.title,user.email)
            from_email = settings.EMAIL_HOST_USER
            to_email = project.created_by.email
            send_mail(subject,message,from_email,to_email)
        else:
            return None
    else:
        return None
Пример #4
0
def create_invitation(sender, instance, created, **kwargs):
    if created:
        html_message = loader.render_to_string(
            'user/activation_email.html', {
                'message':
                'Dear Sir/Madam\n This is the link to create a staff account',
                'link':
                "{}/user/invitation/{}".format(settings.SITE_URL, instance.id),
            })
        text_content = 'Text'
        subject = "You have received a notificaion from {}.".format(
            "Notice Project")
        from_email = settings.EMAIL_HOST_USER
        to_email = instance.email
        send_mail(subject, html_message, from_email, to_email, html=True)
        '''msg = EmailMultiAlternatives(subject, text_content, from_email, to_email)
Пример #5
0
 def save(self, commit=True):
     #Save the provided password in hashed format
     user = super(UserProfilePasswordForm, self).save(commit=False)
     user.set_password(self.cleaned_data["password1"])
     if commit:
         user.save()
     html_message = loader.render_to_string(
         'user/activation_email.html', {
             'message':
             'Dear Sir/Madam <br /> You successfully change your password',
             'link': ""
         })
     subject = "You have received a notificaion from {}.".format(
         "Notice Project")
     from_email = settings.EMAIL_HOST_USER
     to_email = user.email
     send_mail(subject, html_message, from_email, to_email, html=True)
     return user