• 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細

このWikiはいつでも誰でも編集できます

メールによるブログ投稿

提供: WordPress Codex 日本語版
移動先: 案内検索

このページ「メールによるブログ投稿」は一部未翻訳です。和訳や日本語情報を加筆してくださる協力者を求めています

WordPress はプラグインを使ってメール投稿に対応できます。

プラグインを使う

WordPress インストールの設定

WordPress のビルトインメール投稿機能は非推奨になっており、今後のリリースで削除される予定です。代わりに上記のプラグインを使ってください。インストール・設定については各プラグインのドキュメンテーションを参照してください。

WordPress による新規メールチェックのカスタマイズ

Most plugins should manage this for you!

Calling wp-mail.php directly will be deprecated in an upcoming WordPress release, so the old methods of adding code to your footer or manually visiting wp-mail.php are no longer recommended.

Instead, use some method to trigger the action wp-mail.php. If you're using a plugin that doesn't allow you to customize this, you can try the suggestions below.

Action-based functions.php Activation

You can add an action to your active theme's functions.php file. This will check for mail every 15 minutes and does not add any HTML to your theme.

add_action( 'shutdown', 'retrieve_post_via_mail' );
function retrieve_post_via_mail() {
	flush(); // Display the page before the mail fetching begins
	if ( get_transient( 'retrieve_post_via_mail' ) ) { 
		return; // The mail has been checked recently; don't check again
	} else { // The mail has not been checked in more than 15 minutes
		do_action( 'wp-mail.php' );
		set_transient( 'retrieve_post_via_mail', 1, 15 * MINUTE_IN_SECONDS ); // check again in 15 minutes.
	}
}

This method is good for users who would like to avoid using cron jobs, which are configured on the server. Unlike cron jobs, this process will only run when pages on the blog are loaded. Cron jobs run independent of site traffic.

Cron Job の有効化

Set up a UNIX cron job to have your blog periodically view http://example.com/installdir/wp-mail.php using a command-line HTTP agent like wget, curl or GET. The command to execute will look like:

wget -N http://example.com/installdir/wp-mail.php

If you use a different program than wget, substitute that program and its arguments for wget in this line.

Note: Another possibility is to run "php /full/path/to/wp-mail.php" in a cronjob. This will run the php-script using php, without the need for an extra program to run. (You are more likely authorized to run php than wget.)

For more information about setting up a cron job, see:

Note to Windows Users: There are similar programs to cron available if your host runs Windows. For example, VisualCron, Cron for Windows and pycron. Consult these projects' documentation for further information.

Procmail の有効化

If your server uses procmail, a simple .procmailrc in the blogmailaccounts home directory will be sufficient:

Shell=/bin/sh
MAILDIR=$HOME/.maildir/
DEFAULT=$MAILDIR
:0
{
:0Wc
./
:0
| wget -N http://example.com/installdir/wp-mail.php
}

This could be more specific, such as capturing certain subject expressions. Check procmail for more information.

.qmail の有効化

If your server uses qmail to process e-mail, you may be able to use it to call wp-mail.php whenever an e-mail message is delivered. To do this, first create a small shell script to call wp-mail.php. You could call the file wp-mail:

#!/bin/sh
/bin/sh -c "sleep 5; /path/to/php /path/to/your/blog/wp-mail.php > /dev/null" &

The sleep command causes a 5-second delay to allow qmail to finish processing the message before wp-mail.php is called. Note that the ampersand on the end of the line is required. The above script should go in your root directory, and the execute bit should be set (chmod 700). For debugging purposes, you could change /dev/null to a filename to save the output generated by wp-mail.php.

Then all you need to do create/modify the appropriate .qmail file to call your shell script. Add the following line to the .qmail file for your mailbox name:

|/path/to/your/root/directory/wp-mail

See your ISP's documentation for use of .qmail files. Naming conventions may vary for different ISPs.

最新英語版: WordPress Codex » Post to your blog using email最新版との差分