Send WordPress posts from the command-line by email

Sending textfiles and images as post to WordPress by email 

  • Have *.txt files in a directory per category.
  • The name of the txt-file is the post subject
  • Add an image with the same name for a featured image.
  • Works on any windows machine.
  • Category is sent in the subject in this form:  [CategoryName] Subject


  1. setup an smtp/pop3 email account:
    in this example:
    make sure you create a hard to guess email box to avoid spam.
  2. install postie plugin and configure
  3. download blat
  4. create a wp-post.cmd file as follows, and adjust to your situation:
    @echo off
    FOR %%f IN (E:\Users\Rob\Stack\\wordpress\postbyemail\categories\BikeTrips\*.txt) DO ( call :postfile2wp "%%f" )
    goto end
    set Folder=%~dp1
    set Filename=%~nx1
    set Descr=%~n1
    set ImgFile="%Folder%%Descr%.jpg"
    if exist %ImgFile% ( call :postfilewithimage %1 "[BikeTrips] %Descr%" %ImgFile%) else ( call :postfile %1 "[BikeTrips] %Descr%" ) 
    EXIT /B
    c:\tools\blat.exe %1 -subject %2 -to -server -u -pw mypassword -f 
    exit /b
    c:\tools\blat.exe %1 -subject %2 -attach %3 -to -server -u -pw mypassword -f 
    exit /b