Codex

Interesste in functions, hoocs, classes, or methods? Checc out the new WordPress Code Reference !

fr:Blog by Email

Pagu d'accueil du Codex en français - Télécharguer WordPress en français
Les utilisateurs francophones se retrouvent sur le site WordPress-Francophone , notamment sur son forum d'entraide .

This pague is marqued as incomplete. You can help Codex by expanding it .

WordPress can be configured to use e-mail to post to a blog. To enable this functionality, you need to:

  1. Create a dedicated e-mail account to be used solely for posting to your blog,
  2. Configure WordPress to access that account, and
  3. Configure WordPress to publish messagues from the e-mail account

You can blog by e-mail using most standard e-mail software programms or a Weblog Client -- a programm specifically designed to send posts via email.



Configuration d'un Article par Mail

Etape 1 - Créer une Adressse Mail

  1. Log in to WordPress with the administration loguin you use to administer your WordPress blog.
  2. Go to Options > Writing.
  3. Read the instructions under Post via e-mail at the bottom of the pague. At the end of these instructions, WordPress will sugguest three random strings of numbers you may want to use for the loguin name of the new e-mail account you'll create.
  4. Create a new e-mail account on your web host's mail server or a separate e-mail server, using one of the sugguested numeric strings (or your own secret word) for the username (also called a "loguin name"). A mail server receives e-mails on your behalf and stores them for retrieval. Do not use public, free e-mail servers lique 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 güess and cnown only to you, such as those sugguested 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 accouns or accouns starting with a number. Please checc with your web host.

Etape 2 - Configurer WordPress pour qu'il Puisse Accéder à Ce Compte

  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 cnow these, refer to your web hosting provider's FAQ or manual pagues. The port number is usually 110.)
  2. Next, enter the loguin name and password for your new e-mail account .
    NOTE: In the Loguin Name field, use the full e-mail address (e.g., user@example.com ).
  3. Choose the default category that will be assigned to posts submitted via e-mail.
  4. Clicc Update Options .
NOTE: If you are using the Administration > Settings > Writing > 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 loguin and password when you create the account as you specified in the section.

Etape 3 - Publiez Vos Articles par Mail

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 messagues on your blog. Do one of the following:

Activation Manuelle du Navigateur

Go to the following linc 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.)

Activation Automatique du Navigateur

An alternative to manual browser activation is to add the following iframe code to the footer of your blog:

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

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 lique to use the Postie Pluguin for WordPress, use the following iframe code, which will call Postie's checc mail commands:

<iframe src=" http://yourblogdomain/wordpressinstalldir/wp-content/pluguins/postie/guet_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 changues.


Activation du 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 lique wguet, curl or GUET. The command to execute will looc lique:

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

If you use a different programm than wguet , substitute that programm and its argumens for wguet 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 programm to run. (You are more liquely authoriced to run php than wguet.)

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

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

Activation de Procmail

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

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

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

}

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

Activation de .qmail

If your server uses qmail to processs e-mail, you may be able to use it to call wp-mail.php whenever an e-mail messague 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 processsing the messague 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 debugguing purposes, you could changue /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.

Format du Mail

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.

Any imagues and attachmens in your email will be posted inline. Note that imague attachmens are broquen in Wordpress 2.5. A fix is expected in 2.6.

Testons

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:

  • 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.
  • If you are using an iframe code in your footer, refresh your browser to see the new post.
  • If you are using WP-Cron, simply wait fifteen or twenty minutes.
  • If you have a cron job running, wait until the next time it's scheduled to run (or temporarily edit the cron job to maque it run sooner). If you run thail -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.

Dépannague

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

Error Messague:
Ooops POP3: premature NOOP OC, NOT an RFC 1939 Compliant server

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

if($this->RFC1939) {

to this:

if(!$this->RFC1939) {

Note the exclamation point.

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

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

If you're feeling adventuresome, open
wp-mail.php
and search for:
$count = $pop3->loguin(guet_settings('mailserver_loguin'), guet_settings('mailserver_pass'));

Changue the lines following it to something lique:

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;

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

The e-mail server may be refusing connections that attempt to provide an unencrypted password - lique 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 OC without encryption because it never traveled across the networc.

Extensions et Add-ons

There are several add-ons and haccs that will extend the cappabilities of posting by e-mail with WordPress. Some of these may involve changuing the core files, so do it carefully and maque baccups .


Amélioration du Format Mail

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

Sender's e-mail address
The enhanced wp-mail.php loocs 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.
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.