Esempio n. 1
0
def sendMail(sender, **kwargs):
    subject= kwargs['instance'].title
    # currentSite = get_current_site(request)
    # message="http://{d}/{s}".format(d = currentSite.get_host(), s = kwargs['instance'].slug)
    # message='http://{}'.format(Site.objects.get_current().domain)
    message = "http://165.22.80.249:8000/detail/{}".format(kwargs['instance'].slug)
    sender = settings.EMAIL_HOST_USER
    receiver= []
    sub = Subscribe.objects.all()
    for i in sub:
        if i.email not in receiver:
            receiver.append(i.email)
    send_mail( subject, message, sender, receiver)
Esempio n. 2
0
def indexmail(request):
    if request.method == 'POST':
        # mail = User.objects.filter(is_active=True).exclude(email='').values_list('email', flat=True)
        receiver = []
        for user in User.objects.all():
            receiver.append(user.email)
        asunto = request.POST.get('asunto')
        cuerpo = request.POST.get('cuerpo')
        send_mail(asunto,
                  cuerpo,
                  settings.EMAIL_HOST_USER,
                  receiver,
                  fail_silently=False)
    return render(request, 'mail.html', {})
Esempio n. 3
0
def save_comment(sender, instance, **kwargs):
    receiver = []
    receiver.append(config.WEBSITE_ADMINISTRATION_EMAIL)
    body = render_to_string(
        'email/new-contact-alert.txt', {
            'name': instance.name,
            'email': instance.email,
            'content': instance.content,
            'date_posted': instance.date_posted,
        })
    email_dict = {
        'receiver': receiver,
        'fail_silently': False,
        'subject': config.EMAIL_TEMPLATES['new-contact-alert']['subject'],
        'body': body,
    }
    send_email_out(email_dict)
Esempio n. 4
0
def save_subscription(sender, instance, **kwargs):
    receiver = []
    receiver.append(instance.subscription_email)
    method = 'confirm-subscription'
    subscribe_link = f"{config.WEBSITE_URL}/mail?action={method}&user-id={instance.pk}&hash={instance.subscribe_hash}"
    unsubscribe_link = f"{config.WEBSITE_URL}/mail?action=unsubscribe&user-id={instance.pk}&hash={instance.unsubscribe_hash}"
    body = render_to_string('email/subscription.txt', {
        'subscribe_link': subscribe_link,
        'unsubscribe_link': unsubscribe_link,
    })
    email_dict = {
        'receiver': receiver,
        'fail_silently': False,
        'subject': config.EMAIL_TEMPLATES['subscription']['subject'],
        'body': body,
    }
    if instance.active is not True:
        send_email_out(email_dict)
Esempio n. 5
0
def create_profile(sender,instance,created,**kwargs):
    post = Contribution.objects.all().first()
    url = f"""http://127.0.0.1:8000/contributions/detail/{post.id}"""
    receiver = []
    receiver_model = Marketing_Coordinator.objects.filter(faculty=post.author.faculty)

    for receiver_models in receiver_model:
        email = receiver_models.email
        receiver.append(email)
    date = post.date_posted + timedelta(days = 14)
    subject = 'New contribution alert!!'
    html = f"""<p><h3>{post.author.name}</h3> posted a contribution on {post.author.faculty.get_name_display()} newsfeed. <a href='{url}'>Click</a> here to read. Don't forget 
    to make a comment within 14 days which is until <h3>{date.strftime('%d %B %Y')}.</h3></p>"""

    if created:
        try:
            send_mail(subject=subject,html=html,to_email=receiver)
        except:
            pass
Esempio n. 6
0
def save_comment(sender, instance, **kwargs):
    receiver = []
    receiver.append(config.WEBSITE_ADMINISTRATION_EMAIL)
    confirm_link = f"{config.WEBSITE_URL}/mail?action=confirm-comment&comment-id={instance.pk}&hash={instance.confirm_hash}"
    delete_link = f"{config.WEBSITE_URL}/mail?action=delete-comment&comment-id={instance.pk}&hash={instance.confirm_hash}"
    body = render_to_string(
        'email/new-comment-alert.txt', {
            'confirm_link': confirm_link,
            'delete_link': delete_link,
            'blogpost': instance.blogpost_short,
            'comment_short': instance.comment_body_short,
        })
    email_dict = {
        'receiver': receiver,
        'fail_silently': False,
        'subject': config.EMAIL_TEMPLATES['new-comment-alert']['subject'],
        'body': body,
    }
    if instance.confirm_hash != 'confirmed' and not instance.reply:
        send_email_out(email_dict)