diff options
| author | Barry Warsaw | 2011-01-02 23:52:22 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2011-01-02 23:52:22 -0500 |
| commit | 5d0d6a5afa34c61630a6442006e9ff2b87fb0c8d (patch) | |
| tree | 6296162e7f68e2af68f7ed8ab9ccc7f1394ec084 /src/mailman/mta/docs | |
| parent | 1b8c94f4ad4730b3251c9efd667db27245105b6c (diff) | |
| download | mailman-5d0d6a5afa34c61630a6442006e9ff2b87fb0c8d.tar.gz mailman-5d0d6a5afa34c61630a6442006e9ff2b87fb0c8d.tar.zst mailman-5d0d6a5afa34c61630a6442006e9ff2b87fb0c8d.zip | |
LP: #490044 - Support SMTP AUTH.
Added smtp_user and smtp_pass options to the [mta] section to support logging
into the SMTP server. All the underlying support is in Python's smtplib.
Diffstat (limited to 'src/mailman/mta/docs')
| -rw-r--r-- | src/mailman/mta/docs/authentication.txt | 56 | ||||
| -rw-r--r-- | src/mailman/mta/docs/connection.txt | 50 |
2 files changed, 106 insertions, 0 deletions
diff --git a/src/mailman/mta/docs/authentication.txt b/src/mailman/mta/docs/authentication.txt new file mode 100644 index 000000000..9f494be61 --- /dev/null +++ b/src/mailman/mta/docs/authentication.txt @@ -0,0 +1,56 @@ +=================== +SMTP authentication +=================== + +The SMTP server may require authentication. Mailman supports setting the SMTP +user name and password. When the user name and password match what's expected +by the server, everything is a-okay. + + >>> mlist = create_list('test@example.com') + +By default there is no user name and password, but this matches what's +expected by the test server. + + >>> config.push('auth', """ + ... [mta] + ... smtp_user: testuser + ... smtp_pass: testpass + ... """) + +Attempting delivery first must authorize with the mail server. +:: + + >>> from mailman.mta.bulk import BulkDelivery + >>> bulk = BulkDelivery() + + >>> msg = message_from_string("""\ + ... From: aperson@example.com + ... To: test@example.com + ... Subject: My first post + ... Message-ID: <first> + ... + ... First post! + ... """) + + >>> bulk.deliver(mlist, msg, dict(recipients=['bperson@example.com'])) + {} + + >>> print smtpd.get_authentication_credentials() + PLAIN AHRlc3R1c2VyAHRlc3RwYXNz + >>> config.pop('auth') + +But if the user name and password does not match, the connection will fail. + + >>> config.push('auth', """ + ... [mta] + ... smtp_user: baduser + ... smtp_pass: badpass + ... """) + + >>> bulk = BulkDelivery() + >>> response = bulk.deliver( + ... mlist, msg, dict(recipients=['bperson@example.com'])) + >>> dump_msgdata(response) + bperson@example.com: (571, 'Bad authentication') + + >>> config.pop('auth') diff --git a/src/mailman/mta/docs/connection.txt b/src/mailman/mta/docs/connection.txt index 7da16a771..515a773bd 100644 --- a/src/mailman/mta/docs/connection.txt +++ b/src/mailman/mta/docs/connection.txt @@ -49,6 +49,56 @@ We can reset the connection count back to zero. >>> connection.quit() +By providing an SMTP user name and password in the configuration file, Mailman +will authenticate with the mail server after each new connection. +:: + + >>> config.push('auth', """ + ... [mta] + ... smtp_user: testuser + ... smtp_pass: testpass + ... """) + + >>> connection = Connection( + ... config.mta.smtp_host, int(config.mta.smtp_port), 0, + ... config.mta.smtp_user, config.mta.smtp_pass) + >>> connection.sendmail('anne@example.com', ['bart@example.com'], """\ + ... From: anne@example.com + ... To: bart@example.com + ... Subject: aardvarks + ... + ... """) + {} + >>> print smtpd.get_authentication_credentials() + PLAIN AHRlc3R1c2VyAHRlc3RwYXNz + + >>> reset() + >>> config.pop('auth') + +However, a bad user name or password generates an error. + + >>> config.push('auth', """ + ... [mta] + ... smtp_user: baduser + ... smtp_pass: badpass + ... """) + + >>> connection = Connection( + ... config.mta.smtp_host, int(config.mta.smtp_port), 0, + ... config.mta.smtp_user, config.mta.smtp_pass) + >>> connection.sendmail('anne@example.com', ['bart@example.com'], """\ + ... From: anne@example.com + ... To: bart@example.com + ... Subject: aardvarks + ... + ... """) + Traceback (most recent call last): + ... + SMTPAuthenticationError: (571, 'Bad authentication') + + >>> reset() + >>> config.pop('auth') + Sessions per connection ======================= |
