예제 #1
0
def send_autoreply(sender, mailbox, armessage):
    if armessage.fromdate > timezone.now():
        return
    if armessage.untildate is not None \
        and armessage.untildate < timezone.now():
        armessage.enabled = False
        armessage.save()
        return

    try:
        lastar = ARhistoric.objects.get(armessage=armessage.id, sender=sender)
        PostfixAutoreply().load()
        timeout = parameters.get_admin("AUTOREPLIES_TIMEOUT",
                                       app="postfix_autoreply")
        delta = datetime.timedelta(seconds=int(timeout))
        now = timezone.make_aware(datetime.datetime.now(),
                                  timezone.get_default_timezone())
        if lastar.last_sent + delta > now:
            sys.exit(0)
    except ARhistoric.DoesNotExist:
        lastar = ARhistoric()
        lastar.armessage = armessage
        lastar.sender = sender

    sendmail_simple(mailbox.user.encoded_address, sender, armessage.subject,
                    armessage.content.encode('utf-8'))

    lastar.last_sent = datetime.datetime.now()
    lastar.save()
예제 #2
0
def send_autoreply(sender, mailbox, armessage):
    if armessage.fromdate > timezone.now():
        return
    if armessage.untildate is not None \
        and armessage.untildate < timezone.now():
        armessage.enabled = False
        armessage.save()
        return

    try:
        lastar = ARhistoric.objects.get(armessage=armessage.id, sender=sender)
        PostfixAutoreply().load()
        timeout = parameters.get_admin("AUTOREPLIES_TIMEOUT",
                                       app="postfix_autoreply")
        delta = datetime.timedelta(seconds=int(timeout))
        now = timezone.make_aware(datetime.datetime.now(),
                                  timezone.get_default_timezone())
        if lastar.last_sent + delta > now:
            sys.exit(0)
    except ARhistoric.DoesNotExist:
        lastar = ARhistoric()
        lastar.armessage = armessage
        lastar.sender = sender

    sendmail_simple(mailbox.user.encoded_address, sender, armessage.subject,
                    armessage.content.encode('utf-8'))

    lastar.last_sent = datetime.datetime.now()
    lastar.save()
예제 #3
0
파일: views.py 프로젝트: JHei/modoboa
def send_spam(request):
    status, error = sendmail_simple(
        "*****@*****.**",
        request.user.username,
        content="""
This is the GTUBE, the
        Generic
        Test for
        Unsolicited
        Bulk
        Email

If your spam filter supports it, the GTUBE provides a test by which you
can verify that the filter is installed correctly and is detecting incoming
spam. You can send yourself a test mail containing the following string of
characters (in upper case and with no white spaces and line breaks):

XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X

You should send this test mail from an account outside of your network.
""",
    )
    if status:
        return render_to_json_response(_("Message sent"))
    return render_to_json_response(respmsg=error, status=500)
예제 #4
0
파일: amnotify.py 프로젝트: Marx86/modoboa
 def send_pr_notification(self, rcpt, reqs):
     if self.options["verbose"]:
         print "Sending notification to %s" % rcpt
     total = reqs.count()
     reqs = reqs.all()[:10]
     content = render_to_string(
         "amavis/notifications/pending_requests.html", dict(
             total=total, requests=reqs,
             baseurl=self.baseurl, listingurl=self.listingurl
         )
     )
     status, msg = sendmail_simple(
         self.sender, rcpt,
         subject=_("[modoboa] Pending release requests"),
         content=content,
         server=self.options["smtp_host"],
         port=self.options["smtp_port"]
     )
     if not status:
         print msg
예제 #5
0
 def send_pr_notification(self, rcpt, reqs):
     if self.options["verbose"]:
         print "Sending notification to %s" % rcpt
     total = reqs.count()
     reqs = reqs.all()[:10]
     content = render_to_string(
         "amavis/notifications/pending_requests.html",
         dict(total=total,
              requests=reqs,
              baseurl=self.baseurl,
              listingurl=self.listingurl))
     status, msg = sendmail_simple(
         self.sender,
         rcpt,
         subject=_("[modoboa] Pending release requests"),
         content=content,
         server=self.options["smtp_host"],
         port=self.options["smtp_port"])
     if not status:
         print msg
예제 #6
0
파일: views.py 프로젝트: masbog/modoboa
def send_spam(request):
    status, error = sendmail_simple("*****@*****.**",
                                    request.user.username,
                                    content="""
This is the GTUBE, the
        Generic
        Test for
        Unsolicited
        Bulk
        Email

If your spam filter supports it, the GTUBE provides a test by which you
can verify that the filter is installed correctly and is detecting incoming
spam. You can send yourself a test mail containing the following string of
characters (in upper case and with no white spaces and line breaks):

XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X

You should send this test mail from an account outside of your network.
""")
    if status:
        return render_to_json_response(_("Message sent"))
    return render_to_json_response(respmsg=error, status=500)