확장 기능:BounceHandler
출시 상태: 안정 |
|
|---|---|
| 구현 | 훅, 데이터베이스 |
| 설명 | Allows users to handle email bounces |
| 만든 이 |
|
| 최신 버전 | 1.0 (Continuous updates) |
| 호환성 정책 | 스냅샷은 미디어위키와 함께 릴리스됩니다. Master is not backward compatible. |
| MediaWiki | 1.29+ |
| PHP | 5.4+ |
| 데이터베이스 변경 | 예 |
| 가상 도메인 | virtual-bouncehandler |
|
|
| Licence | GNU General Public License 2.0 or later |
| 다운로드 | |
| BounceHandler 확장 기능 번역 (translatewiki.net에서 가능한 경우) | |
| 이슈 | 미해결 작업 · 버그 보고 |
The BounceHandler extension allows wikis to handle bounce emails efficiently, by:
- Generate a VERP "Variable envelope Return-Path" on
UserMailer::sendemail invocations.
- Bounces can be directly fed to the
bouncehandlerAPI from the MTA using a curl POST request
As a result, users whose address is in error are un-subscribed and they are notified through Echo about this the next time they connect on the wiki. More exactly, their address is un-confirmed, and in case MediaWiki requires confirmed emails no emails will be further sent.
설치
- 파일을 다운로드하고
BounceHandler폴더를extensions/디렉토리에 넣어 주세요.
개발자와 코딩 기여자는 Git을 이용해 확장기능을 다운받는 것이 좋습니다.cd extensions/ git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/BounceHandler
- 아래의 코드를 LocalSettings.php 코드의 마지막에 추가합니다.
wfLoadExtension( 'BounceHandler' );
- 갱신 스크립트를 실행합니다. 이 스크립트는 이 확장기능을 필요로 하는 데이터 베이스 테이블을 자동적으로 작성합니다.
완료 – 위키의 ‘Special:Version’에 이동해서, 확장기능이 올바르게 설치된 것을 확인합니다.
Configuration
The extension requires the Mail Transfer Agent (MTA) installed in your mail server to HTTP POST the incoming bounce email to the extension API named as bouncehandler. This can be done by adding the corresponding configurations to your MTA configuration.
Adding bouncehandler router and transport configuration to Exim
You can redirect all your bounce emails to the bouncehandler API directly to do the processing. You can edit your Exim configurations to route all bounce emails to a bounce-handler-router and do HTTP POST to the extension API, which is the recommended method.
Add this to your /etc/exim4/exim4.conf
Under the variable declaration section:
VERP_BOUNCE_LOCALPART_REGEXP = \N^wiki-[\w.]+-\w+-\w+-[+/\w]+$\N
under router configuration:
# Route bounce emails
mw_verp_api:
driver = accept
domains = +verp_domains
condition = ${if match{$local_part}{VERP_BOUNCE_LOCALPART_REGEXP}{true}{false}}
transport = mwverpbounceprocessor
under transports, we need to write the configuration that would HTTP POST to our bouncehandler API
# POST VERP bounce emails to a MediaWiki 'bouncehandler' API 822
mwverpbounceprocessor:
driver = pipe
command = /usr/bin/curl --interface 127.0.0.1 -H 'Host: example.com' http://example.com/api.php -d "action=bouncehandler" -d "format=json" --data-urlencode "email@-" -o /dev/null
user = nobody
group = nogroup
You can find more details in this blog-post "POST-ing bounce email to a Mediawiki API directly from exim".
Adding bouncehandler configuration to Postfix
This section shows how the BounceHandler extension can be configured to handle bounced emails from Postfix, unlike the above section which shows how to do the same with Exim.
First of all, please make sure that Postfix & the package "postfix-pcre" are installed. Once these two installed, open up /etc/postfix/main.cf and add the following in the end of the file:
virtual_alias_maps = pcre:/etc/postfix/virtual
Also, make sure that alias_maps is set to the following:
alias_maps = hash:/etc/aliases
Save & close that file, and then create a new file called etc/postfix/virtual, , and add the following ode
/wiki-[a-z0-9_.]+-[a-z0-9]+-[a-z0-9]+-[a-z0-9+\/=]+@example.com/ curl_email
This will tell Postfix that all the bounced emails (the ones which have return path matching with the above regex expression) should be passed on to the command specified in the alias 'curl_email'.
Now we need to define curl_email as our alias, so save & close this file, open up /etc/aliases and add the following:
curl_email: "|curl --interface 127.0.0.1 -d action=bouncehandler -d format=json --data-urlencode email@- http://example.com/path-to-mediawiki-install/api.php"
Save & close that file, and now type the following commands, to map your /etc/postfix/ to postfix, and then restart postfix:
sudo postmap /etc/postfix/virtual
sudo postalias /etc/aliases
sudo /etc/init.d/postfix reload
sudo /etc/init.d/postfix restart
Save and close this file, and head over to your MediaWiki's LocalSettings.php and make sure add the following line:
$wgJobRunRate = 0;
Once that is done, save and close this file. To test if this works, send an email to an invalid email to your server and then run:
php maintenance/runJobs.php
To check if your email bounces were captured, check the bounce_records table in your MediaWiki database, and /var/log/mail.log for further testing.
API
The BounceHandler extension installs an API bouncehandler to receive the HTTP POST from the mail server.
The API has a parameter email to which the entire bounce email is URL encoded to.
This helps in avoiding the use of a separate bounce collector inbox or other IMAP features for the extension to work.
Example API call:
http://example.org/api.php?action=bouncehandler&email=This%20is%20a%20test%20email This would send a bounce email with the body This is a test email for processing.
VERP address
The extension creates a unique w:VERP address as the Return Path header to every single email send from the wiki installation. The generated VERP address is of the form
wiki-testwiki-2a-nanrfx-Tn14EQZWaotS2XNn@verpwebhost.wmflabs.org
The general template of the generated VERP address is:
$prefix-$wikiName-base36( $userID )-base36( $timestamp )-base64( hash( $algorithm, $key, $data ) )@$email_domain
| Variable | Description |
|---|---|
| $prefix | The prefix applied to every VERP email. Default to wiki |
| $wikiName | The name of the Wiki on which the extension is running |
| $userID | The user id (int) of the recipient from the MediaWiki user table
|
| $timestamp | The unix time-stamp value at the time of the VERP address generation |
| $data | The string resulting as the concatenation of $prefix,'-',$wikiId,'-',base_convert( $userID, 10, 36),'-' and base_convert( $timestamp, 10, 36) |
| $algorithm | The hashing php-hmac algorithm used to prepare the hash of $prefix |
| $key | The key used to prepare the hash using the hmac algorithm |
| $email_domain | The domain part of the VERP email address |
Parameters
| Configuration | Default | Description |
|---|---|---|
$wgVERPalgorithm
|
'md5'
|
The PHP hashing algorithm you need to employ to generate the VERP return-path address. Can be md5, sha256 etc. More details at [1] |
$wgVERPsecret
|
'MediaWikiVERP'
|
The secret key you need to pass to the PHP HMAC function |
$wgVERPAcceptTime
|
259200 (3 days) |
The threshold time (in seconds) until we are expecting a bounce. Setting it < 3 days will make sure you respond only to the valid bounces. |
$wgVERPprefix
|
'wiki'
|
The prefix of the bounce addresses. |
$wgVERPdomainPart
|
null
|
The domain part of the bounce addresses. null is equivalent to $wgServerName
|
$wgBounceRecordPeriod
|
604800 (1 week) |
The Bounce allowed period (in seconds). Setting it to a week makes sure that we consider a weeks bounce frequency before taking un-subscribe actions. |
$wgBounceRecordLimit
|
10 | Allowed bounces in the given time period. |
$wgBounceHandlerInternalIPs
|
[ '127.0.0.1', '::1' ]
|
The internal IPs that are allowed to use the API. Make sure this is configured correctly, so that no outside user can cause unwanted email un-subscriptions. |
$wgBounceHandlerUnconfirmUsers
|
false
|
Set to true to enable unsubcriptions when bounces are above the threshold.
|
$wgBounceRecordMaxAge
|
5184000 (60 days) |
The period (in seconds) where are kept the records of bounces. Older bounces records are deleted. false to deactivate deletion.
|
$wgBounceHandlerSharedDB
|
false
|
(to be documented) |
$wgBounceHandlerCluster
|
false
|
(to be documented) |
$wgUnrecognizedBounceNotify
|
null
|
Array of email addresses where unrecognized bounces are sent. |
$wgGenerateVERP
|
true
|
Activate VERP addresses. |
| 이 확장 기능은 하나 이상의 위키미디어 프로젝트에서 사용 중입니다. 이것은 아마도 이 확장 기능이 안정적이고 트래픽이 많은 웹 사이트에서 사용할 수 있을 만큼 충분히 잘 작동한다는 것을 의미합니다. 설치된 위치를 확인하려면 위키미디어의 CommonSettings.php 및 InitialiseSettings.php 구성 파일에서 이 확장 기능의 이름을 찾습니다. 특정 위키에 설치된 확장 기능의 전체 목록은 위키의 Special:Version 문서에서 볼 수 있습니다. |
- Stable extensions/ko
- Hook extensions/ko
- Database extensions/ko
- BeforeCreateEchoEvent extensions/ko
- LoadExtensionSchemaUpdates extensions/ko
- UserMailerChangeReturnPath extensions/ko
- GPL licensed extensions/ko
- Extensions in Wikimedia version control/ko
- All extensions/ko
- Extensions used on Wikimedia/ko
- Email extensions/ko
