A simple SMTP server (in Python)

前端 未结 9 2684
小鲜肉
小鲜肉 2020-12-12 17:09

Could you please suggest a simple SMTP server with the very basic APIs (by very basic I mean, to read, write, delete email), that could be run on a linux box? I just need to

9条回答
  •  臣服心动
    2020-12-12 17:55

    If you want to quickly test Django's send_mail with hasen's answer above:

    # Skip lines 3 and 4 if not using virtualenv.
    # At command prompt
    
    mkdir django1
    cd django1
    virtualenv venv
    source venv/bin/activate
    pip install django==1.11
    django-admin startproject django1 .
    
    # run the Django shell
    
    python manage.py shell
    
    # paste into shell following:
    
    from django.core.mail import send_mail
    
    send_mail(
        'Subject here',
        'Here is the message.',
        'from@example.com',
        ['to@example.com'],
        fail_silently=False,
    )
    # This should write an email like the following:
    
    Content-Type: text/plain; charset="utf-8"
    MIME-Version: 1.0
    Content-Transfer-Encoding: 7bit
    Subject: Subject here
    From: from@example.com
    To: to@example.com
    Date: Wed, 02 May 2018 02:12:09 -0000
    Message-ID: <20180502021209.32641.51865@i1022>
    
    Here is the message.
    

    Not necessary to have valid values in send_mail function. Above values will work just fine with hasen's example.

提交回复
热议问题