Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

pt-br:Publicando por Email

O WordPress pode ser configurado para postar por e-mail. Para ativar esta funcionalidade, é necessário:

  1. Criar uma conta de e-mail exclusivamente para postagem em seu blog
  2. Configurar o WordPress para acessar a conta de e-mail
  3. Configurar o WordPress para publicar mensagens da conta de e-mail

Você pode postar por e-mail usando o programas de e-mail padrão mais ou um software de Postagem Desktop - que é um programa projetado especificamente para mandar postagens.

Limitações:

  • Problemas com caracteres, dependendo do idioma
  • Apenas texto simples


Configurando Post via E-mail

Passo 1 - Criar uma conta de email

  1. Entrar no WordPress como administrador que você usar para administrar seu blog WordPress.
  2. Vá em Configurações > Escrita.
  3. Leia as instruções em 'Enviar por e-mail', na parte inferior da página. No final destas instruções o WordPress irá sugerir três seqüências aleatórias de números que você pode querer usar como nome de login da conta de e-mail nova que você criar.
  4. Crie uma nova conta de correio-electrónico no servidor de seu host de correio ou um servidor de e-mail qualquer, usando uma das seqüências numéricas sugerido (ou a sua própria palavra secreta) para o nome de usuário (também chamado de nome "login"). Um servidor de correio recebe e-mails nesse nome e armazena-os para a recuperação. Não use servidores de e-mail como Yahoo!, Hotmail, etc, para esta conta.

Nota: É altamente recomendável que você use um endereço de e-mail que mais se parece com uma senha - ou seja, um nome de conta de e-mail que é muito difícil de adivinhar e conhecida somente por você. Qualquer e-mail enviado para este endereço será automaticamente postado em seu blog. Esteja ciente, no entanto, que alguns servidores de e-mail não permitem números no nome de login. Por favor, verifique com seu host.

Passo 2 - Configurar o WordPress para acessar sua conta nova

  1. Quando você terminar de criar a nova conta de e-mail, volte ao painel de Opções de Escrita e preencha o nome do servidor de email enúmero de porta usada por seu provedor de hospedagem na web. (Se você não sabe, consulte o seu provedor de hospedagem ou FAQ do servidor. O número da porta é normalmente 110).
  2. Em seguida, digite o nome de login e senha para a nova conta de e-mail. No campo Login Name, use o endereço completo e-mail (por exemplo, usuário@exemplo.com.br).
  3. Escolha a categoria padrão que será atribuído às mensagens enviadas por e-mail.
  4. Clique emUpdate Options.


Passo 3 - Publicar Postagens

Você criou a conta de e-mail nova e configurou o seu WordPress para aceitar e-mails a partir dessa conta, mas você ainda precisará configurar o WordPress para publicar essas mensagens de e-mail em seu blog. Faça um dos seguintes procedimentos:


cb-help.png
Artigo parcialmente traduzido ou que precisa de tradução
Este documento está parcialmente traduzido ou precisa ser traduzido. Toda a tradução é feita por voluntários e você pode ser um deles.
ParticiparArtigos para traduzirFórum de SuporteTodos os Artigos

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

Automated Browser Activation

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

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

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.

Cron Job Activation

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 Activation

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 Activation

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.

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.

Posting by email does not support attachments and any attachments sent with the email will appear in their raw form in the blog post.

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:

  • 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 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.
  • Your email may be recorded with a post status of 'Pending Review' rather than 'Published'. If the status is 'Pending Review', then the post will be visible in the Dashboard but will not be visible in the Blog. By default, wp-mail.php will validate the sending email address against the email addresses for authorized users. If the email address is found, the post status will be 'Published', otherwise the status will be 'Pending Review'.

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

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

if($this->RFC1939) {

to this:

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'));

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;

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.

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.

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.

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:

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

Blog By Email From Yahoo! Mail, Gmail and Hotmail

By default, most web-based email clients send messages in HTML formatting, which Wordpress's blog-by-email feature filters out.

To get around this, you must select "plain text" before sending.

In Yahoo! Mail, the button for switching to plain text is just to the right of the SUBJECT field. In Gmail a similar button is located at the right end of the text formatting tool bar. Hotmail's is found next to the SPELL CHECK button in the email action bar which is located above the email message.

Official category support

Bug request: Post via e-mail's Category: allow specification from inside the mail too



brasil-1.png
A documentação do WordPress em Português do Brasil.
Todas as comunidades lusófonas também são bem-vindas! Adicione {{Codex-pt}} em seus artigos.