# Path: hyperkitty/lib/mailman.py
# def get_mailman_client():
# def subscribe(list_address, user):
#     def __init__(self, name):
# def sync_with_mailman():
# class FakeMMList:


from django.core.exceptions import SuspiciousOperation
from django.core.mail import EmailMessage
from mailmanclient import MailmanConnectionError
from hyperkitty.lib import mailman
# any later version.
#
# HyperKitty is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# HyperKitty.  If not, see <http://www.gnu.org/licenses/>.
#
# Author: Aurelien Bompard <abompard@fedoraproject.org>
#





class PostingFailed(Exception):
    pass


def post_to_list(request, mlist, subject, message, headers=None,
                 attachments=None):
    if not mlist:
        # Make sure the list exists to avoid posting to any email addess
        raise SuspiciousOperation("I don't know this mailing-list")
    if headers is None:
        headers = {}
    # Check that the user is subscribed
    try:

# Path: hyperkitty/lib/mailman.py
# def get_mailman_client():
# def subscribe(list_address, user):
#     def __init__(self, name):
# def sync_with_mailman():
# class FakeMMList:


# Path: hyperkitty/lib/posting.py
from django.core.exceptions import SuspiciousOperation
from django.core.mail import EmailMessage
from mailmanclient import MailmanConnectionError
from hyperkitty.lib import mailman

# any later version.
#
# HyperKitty is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# HyperKitty.  If not, see <http://www.gnu.org/licenses/>.
#
# Author: Aurelien Bompard <abompard@fedoraproject.org>
#





class PostingFailed(Exception):
    pass


def post_to_list(request, mlist, subject, message, headers=None,
                 attachments=None):
    if not mlist:
        # Make sure the list exists to avoid posting to any email addess
        raise SuspiciousOperation("I don't know this mailing-list")
    if headers is None:
        headers = {}
    # Check that the user is subscribed
    try:

        mailman.subscribe(mlist.name, request.user)