WordPress:Blog by Email

来自站长百科
Fludlen讨论 | 贡献2008年3月29日 (六) 14:43的版本
跳转至: 导航、​ 搜索
可打印版不再被支持且可能有渲染错误。请更新您的浏览器书签并改用浏览器默认的打印功能。

模板:Rename

WordPress can be configured to use e-mail to post to a blog. To enable this functionality, you need to: WordPress可以用邮件写文章发送到博客上。要运行这个功能,你需要:

  1. Create a dedicated e-mail account to be used solely for posting to your blog,
  2. 创建一个单独的电子邮件帐户,只用来给你的博客发送文章。
  3. Configure WordPress to access that account, and
  4. 设置WordPress接近那个帐户,并且
  5. Configure WordPress to publish messages from the e-mail account
  6. 设置WordPress发表来自电子邮件帐户的文章

You can blog by e-mail using most standard e-mail software programs or a Wordpress:Weblog Client -- a program specifically designed to send posts via email.

使用最标准的电子邮件软件程序或者一个博客软件-一个专门为通过邮件发送博客文章而设计的程序,你可以通过电子邮件来写博客。

Note: WordPress 2.2 users are experiencing problems with posting via e-mail. A patch has been issued to fix this problem.

注:WordPress2.2的用户遇到了通过电子邮件发表博客文章的麻烦。已经发布了一个补丁来解决这个问题。


Setting Up Post via E-mail

通过电子邮件设置文章

Step 1 - Create an e-mail account

第一步 – 创建一个电子邮件帐户

  1. Log in to WordPress with the administration login you use to administer your WordPress blog.
  2. 从管理登录的位置登录到你的博客,你就是使用管理登录 来管理你的WordPress博客。
  3. Go to Options > Writing.
  4. 转到选项 > 写。
  5. Read the instructions under Post via e-mail at the bottom of the page. At the end of these instructions, WordPress will suggest three random strings of numbers you may want to use for the login name of the new e-mail account you'll create.
  1. 在页面的底部阅读一下通过电子邮件写博客。在这些说明的结尾,WordPress会给你三串随机排的数字,你可能想使用这写数字作为你创建的电子邮件帐户的注册名。.


  1. Create a new e-mail account on your web host's mail server or a separate e-mail server, using one of the suggested numeric strings (or your own secret word) for the username (also called a "login name"). A mail server receives e-mails on your behalf and stores them for retrieval. Do not use public, free e-mail servers like Yahoo, Hotmail, etc., for this account.
    Note: It is strongly recommended that you use a "secret" address - that is, an e-mail account name that is very difficult to guess and known only to you, such as those suggested by WordPress. Any e-mail sent to this address will automatically be posted to your blog. Be aware, however, that some e-mail servers do not allow numbers-only e-mail accounts or accounts starting with a number. Please check with your web host.
  1. 在你的网络主机的邮件服务器或者一个单独的电子邮件服务器上创建一个新的电子邮件帐户,使用提供的数字串中的其中一串(或者你自己的保密的命令)作为用户名(也称作"登录名")。一个邮件服务器代表你来接受电子邮件,并且将电子邮件保存以便于提取。不要为这个帐户使用一些公共的免费的电子邮件服务器像雅虎,Hotmail,等等。
    Note: 强烈推荐你使用一个"保密的" 地址—就是一个很难猜到的电子邮件帐户名而且只有你自己知道这个账户名,例如WordPress建议使用的这些地址。

任何电子邮件发送到这个地址,就会自动地粘贴到你的博客上。但是,要明白,有些电子邮件服务器不允许只含有数字的电子邮件帐户或者由一个数字开始的电子邮件帐户。请与你的网络主机核实一下。

Step 2 - Configure WordPress to access your new account

第二步 – 设置WordPress接近你的新帐户

  1. When you are done creating the new e-mail account , return to the Writing Options panel and fill in the name of the mail server and port number your web hosting provider uses. (If you don't know these, refer to your web hosting provider's FAQ or manual pages. The port number is usually 110.)
  1. 当你创建好了新的电子邮件帐户后,返回到写选项面板并且填上你的网络主机供应商使用的电子邮件服务器端口数字(如果你不知道这些,请查阅你的网络主机供应商的常见问题解答或者手册指南页面。端口数字通常是110.)
  1. Next, enter the login name and password for your new e-mail account .
    NOTE: In the Login Name field, use the full e-mail address (e.g., user@example.com).
  1. 然后,为你的新帐户输入登录名e密码 .
    NOTE:在登录名一栏,使用完整的电子邮件地址(例如,user@example.com)。


  1. Choose the default category that will be assigned to posts submitted via e-mail.
  2. 给通过电子邮件上交的博客文章,选择一个默认分配的种类。
  1. Click Update Options .
  2. 点击更新选项
NOTE: If you are using the Writing Options > Post via e-mail section to specify the e-mail address before you've actually created the e-mail account, remember to use the same login and password when you create the account as you specified in the section.

如果在你真正创建电子邮件帐户之前,你使用了写选项 > 通过电子邮件写博客部分来指定电子邮件地址,请记住当你创建帐户时,要使用与你在那个部分规定的登录和密码。


Step 3 - Publish Your E-mail Posts

第三步 – 发表你的电子邮件文章

You've created the new e-mail account and configured your WordPress blog to accept e-mails from that account, but you still need to set up WordPress to publish those e-mail messages on your blog. Do one of the following:

你已经创建了新的电子邮件帐户而且设置了你的WordPress博客从那个帐户中接受电子邮件,但是你仍然哟啊设置WordPress来发表你的博客上的这些电子邮件信息。做一下以下中的一步:


Manual Browser Activation

动手激活浏览器

Go to the following link http://example.com/installdir/wp-mail.php immediately after you send an e-mail to your new e-mail account. (Note: You must do this every time you send a new post.)

在你向你的新的电子邮件帐户发送了一封电子邮件之后,立马转到以下的链接http://example.com/installdir/wp-mail.php。(注:你每发一封新的文章,都要这样做。)


Automated Browser Activation

浏览器自动激活

An alternative to manual browser activation is to add the following iframe code to the footer of your blog: 与动手激活浏览器相对的方法是在你的博客页脚添加以下的iframe代码:

<iframe src="http://yourblogdomain/wordpressinstalldir/wp-mail.php" name="mailiframe" width="0" height="0" frameborder="0" scrolling="no" title=""></iframe>


<iframe src="http://yourblogdomain/wordpressinstalldir/wp-mail.php" name="mailiframe" width="0" height="0" frameborder="0" scrolling="no" title=""></iframe>


Edit the above line of code so that it refers to the location of your wp-mail.php file. Add this line of code to the footer.php file in the directory for whatever theme you are using (don't include it within an HTML paragraph).

编辑上的代码行,这样它就能指向你的wp-mail.php 文件的位置。将这行代码添加到你使用的任何主题的目录上的footer.php 文件上。(不要放到一个HTML段落中)。

You may have to refresh your blog to see the new post. New users may find this method the most helpful.

也许你要刷新你的博客以看到新的文章。新用户可能发现这个方法最管用。

If you're using or would like to use the Postie Plugin for WordPress, use the following iframe code, which will call Postie's check mail commands:

<iframe src="http://yourblogdomain/wordpressinstalldir/wp-content/plugins/postie/get_mail.php?Submit=Run+Postie" name="mailiframe" width="0" height="0" frameborder="0" scrolling="no" title=""> </iframe>

如果你为或者是想为WordPress使用Postie插件,使用下面的iframe代码,这个代码会访问Postie的检查邮件命令行:

<iframe src="http://yourblogdomain/wordpressinstalldir/wp-content/plugins/postie/get_mail.php?Submit=Run+Postie" name="mailiframe" width="0" height="0" frameborder="0" scrolling="no" title=""> </iframe>


Add this code to your footer, and the next time anyone goes to your blog, your new emails will be automatically posted, so you need to do nothing but send them. You may have to refresh the blog to see the changes.

将这个代码添加到你的页脚上,这样下次任何人访问你的博客的时候,你的新邮件会自动地粘贴上去。这样除了发送邮件外,你什么也不要做。你也许要刷新博客看看发生的变化。


WP-Cron Plugin Activation

WP-Cron 插件激活

Download, install, and activate the WP-Cron Plugin. It will work in the background without user intervention to update your site about every 15 minutes.

下载,安装,激活WP-Cron插件。它会在没有用户干涉的幕后工作,每15分钟更新一下你的站点。

Cron Job Activation

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:

设置一个UNIX cron职位使你的博客定时性地看http://example.com/installdir/wp-mail.php使用一个命令行像wget, curl 或者GET那样的HTTP中介。要执行的命令可能看起来像:


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

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.

如果你使用了一个与wget不同的程序,在这一行中将那个程序和它的论点替换为wget

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.)

注:另一种可能性是在一个cronjob中运行"php /full/path/to/wp-mail.php"。这个会使用php来运行php-script,不需要一个额外的程序来运行。(你更可能被授权来运行php而不是wget)

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

更多的关于设置一个cron职位的信息,请看:

  • Your hosting provider's FAQ or manual pages
  • 你的主机供应商的常见问题解答或者手册页面

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.

Windows 用户注意:如果你的主机运行Windows,有与cron相似的程序。例如,可视的Cron, Windows 的Cronpycron.更多信息,请参考一下这些项目的文件。


Procmail Activation

Procmail 激活

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

Shell=/bin/sh<br>
MAILDIR=$HOME/.maildir/
DEFAULT=$MAILDIR
:0
{
:0Wc
./

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

}





如果你的服务器使用 procmail,博客邮件帐户首页目录上一个简单的 .procmailrc 就足够了:

Shell=/bin/sh<br> 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.

这个可能更加地详细和明确,例如夺取一些特殊的主题表述。更多信息请查看procmail

.qmail Activation

.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" &


如果你的服务器使用qmail来处理一个电子邮件,无论何时一封电子邮件发送了,你都可以用它来访问wp-mail.php。要做到这一点,首先创建一个小的shell脚本来访问wp-mail.php。你可以访问文件wp-mail:

  1. !/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.

sleep命令行,在允许qmail在wp-mail.php被访问之前完成处理信息,造成了5秒钟的延误。注意行结尾的&是必须的。以上的脚本应该归入到你的根目录上,而且执行的位应该设置为(chmod 700)。为了调适,你可以将/dev/null改为一个文件名,将由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

然后你所要做的就是创建/更改合适的.qmail文件来访问你的shell脚本。为你的邮箱名的.qmail 文件加上以下这一行:

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


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

看看.qmail 文件的你的ISP的文件使用。不同的ISPs命名传统可能不同。

Email Format

邮件格式

WordPress will use the Subject line of your email for the title of the post, and all body of the email will be used as the content of the post, with common HTML tags stripped. WordPress will file the post under whichever category is selected for "Usual Category" in Step 1, and will use Site Admin as the poster.

WordPress会将你的邮件的主题名作为文章的标题,邮件的所有部分会被用作文章的内容,除去普通的HTML 标签。WordPress会将第一步中任何选为"通常的 种类"中的种类下的文章归档,并且使用站点管理作为发送器。


Any images and attachments in your email will be posted inline.

你的邮件中的任何图像和附件都会被发送进来。

Testing

测试

To test your configuration, simply send an e-mail to yournewaccount@yourmaildomain (or to user@yourmaildomain if you used the .qmail forwarding setup). Then do the following:


测试你的配置,只要向yournewaccount@yourmaildomain (或者向 user@yourmaildomain 如果你使用.qmail 推进的配置)发送一封电子邮件。然后做下面的步骤:


  • If you have no automated system set up, simply view http://example.com/installdir/wp-mail.php in your browser. The script should tell you that it found an e-mail, and print details of the post it made. Then view your blog again to see your email posted.
  • 如果你没有设置自动系统,只要在你的浏览器中看看http://example.com/installdir/wp-mail.php。脚本会告诉你它发现了一封电子邮件,并且印出了文章的详细信息。然后再次看看你的博客,看看粘贴进的邮件。
  • If you are using an iframe code in your footer, refresh your browser to see the new post.
  • 如果你在脚页中使用了iframe代码,刷新你的浏览器看看新的文章。
  • If you are using WP-Cron, simply wait fifteen or twenty minutes.
  • 如果你使用WP-Cron,只要等十五或者二十分钟就行了。
  • If you have a cron job running, wait until the next time it's scheduled to run (or temporarily edit the cron job to make it run sooner). If you run tail -f /var/log/cron in a terminal, you'll be able to see the job create its log entry when it's finished running. When that happens, just view the site in your web browser to see your email posted.

如果你在运行一个cron任务,等到它下一次预定运行的时间(或者临时地编辑一下cron任务使它运行地更快)。如果你在一个终端运行后部-f /var/log/cron,当任务完成运行时,你可以看见任务创建的运行日志。到那时,只要在你的网络浏览器上看看你的站点,看看你发送发表上去的电子邮件。

Troubleshooting

发现并修理故障

If you receive the following error messages, follow the procedures below.

如果你收到了下面的错误信息,遵循以下的步骤。

Error Message:

Ooops POP3: premature NOOP OK, NOT an RFC 1939 Compliant server

Error Message:

Ooops POP3: premature NOOP OK, NOT an RFC 1939 Compliant server


For this error, open wp-includes/class-pop3.php and change this line:

if($this->RFC1939) {

to this:

if(!$this->RFC1939) {

对于这一个错误,打开wp-includes/class-pop3.php并且将这一行: if($this->RFC1939) {

改为: if(!$this->RFC1939) {


Note the exclamation point.

注意一下那个感叹号。

Error Message: There does not seem to be any new mail

错误消息: 好像没有什么新的邮件


This error is a bit of a misnomer - the test just checks to see if anything was retrieved.

这个错误有点用词不当-测试只是检查看看有没有什么重新得到了什么东西。

If you're feeling adventuresome, open

wp-mail.php

and search for:

$count = $pop3->login(get_settings('mailserver_login'), get_settings('mailserver_pass'));

如果你觉得有一点冒险,打开

wp-mail.php

并且搜索:

$count = $pop3->login(get_settings('mailserver_login'), get_settings('mailserver_pass'));


Change the lines following it to something like: 将它下面的行改为:

  if (0 == $count) :
    echo "There does not seem to be any new mail. <br/>\n";
    echo "count = $count<br/> \n"; 
    echo "$pop3->ERROR \n";
    exit;
  endif;


  if (0 == $count) :
    echo "看起来好像没有什么新邮件。 <br/>\n";
    echo "count = $count<br/> \n"; 
    echo "$pop3->ERROR \n";
    exit;
  endif;


You'll then be presented with a more informative message.

然后你得到一个更详细的讯息。

The e-mail server may be refusing connections that attempt to provide an unencrypted password - like POP3. If your webserver and e-mail server are on the same physical computer, you can specify localhost or 127.0.0.1 as the mail server. That traffic is assumed to be OK without encryption because it never traveled across the network.

电子邮件服务器可能会拒绝试着提供一个加密的密码-像POP3的连接。也许你的网络服务器和你的电子邮件服务器都真实地在一台电脑上,你可以将本地主机 or 127.0.0.1规定为邮箱服务器。假定流量是好的,没有加密,因为它从来不在网络中流经。

Extensions and Add-ons

扩充和附件

There are several add-ons and hacks that will extend the capabilities of posting by e-mail with WordPress. Some of these may involve changing the core files, so do it carefully and make backups.

有几个附件和插件会扩展WordPress通过电子邮件写博客的能力。其中的一些可能包括改变核心软件,因此要仔细地做,同时做文件备份

Enhanced Functionality Hack

增强功能性插件

One replacement file for the original wp-mail.php file has been created:

  • Postie supports posting to categories, automatic removal of email signatures, POP3/IMAL (+SSL) and more.

wp-mail.php文件的替换文件已经创建了:

  • Postie支持向种类发送,自动移动电子邮件签名,POP3/IMAL (+SSL)以及更多的。

Hack E-mail Format

破解电子邮件形式

The following enhancements may be made to your wp-mail.php so your e-mail will be translated into metadata for your post:

你的wp-mail.php要做以下的改进,这样你的电子邮件中的文章会被翻译成元数据:

Sender's e-mail address
The enhanced wp-mail.php looks up the email address you send from in its user database. If there is a match with any user there, it files the post under that user. If there is no match, it drops the e-mail and does not create a post in the blog. (Great for security and spam prevention.) It is set by the From field.

;发送者的电子邮件地址:提高了的wp-mail.php在它的用户数据库中查找你发送的电子邮件地址。如果对那儿的用户有一个匹配,它就会吧文章归档到那个用户的下面。如果没有匹配,它扔下电子邮件,在博客中也没有创建一篇文章。(对于安全和防止垃圾广告非常强大。)它由From区设置。

Subject line
If [n] is present anywhere in the subject line of your email, the e-mail will be filed under the category numbered n. Otherwise, it will be posted under whichever category is selected for "Usual Category" in Step 1. Example: [1] This is a Test! would be posted as "This is a Test!", filed under General.

;主题行:如果你的电子邮件的主题栏中的任何位置上有[n],电子邮件会归档到n号的类别上。否则的话,它就会发送到任何在第一步时为"通常的类别"选择的任何类别上。例如:[1] 这是一个测试! 会以 "这是一个测试!"发送,归档在 通常 下。