WordPress Remote Poster v.03
March 27, 2011 in Ask-A-Geek Exclusives by The Geek
WordPress Remote Poster v.03
—————————————————–
Script developed by and copyright by Ask-A-Geek.com. Ask-A-Geek.com assumes no liability and makes no claim of guarantee regarding the use of this script.
License: Free for individuals, corporations and government agencies. Do not reproduce or redistribute this script without written permission from Ask-A-Geek.com
—————————————————–
At a glance
————————————
1 ) About
2 ) Version Release Date
3 ) Requirements
4 ) How to install on a server
5 ) How to configure the script
6 ) List of shortcodes
7 ) How to use shortcodes
8 ) Examples of how to use the shortcodes
9 ) Questions? Problems? Love it?
1) About
————————————
WordPress Remote Poster allows users to post to their WordPress blogs by sending an email to themselves. The WordPress Remote Poster reads the emails, pulls out the neccessary information and feeds it to WordPress automatically allowing a user to post to their blog from anywhere they have an internet connection. It finishes up by removing the emails from the server.
What makes this script different from other WordPress posters is its nature of security and integrity. In no way does WordPress Remote Poster interact with the database used to host the blog data. It navigates the forms as a user would and posts the information as if it were done manually. This ensures the database is secure and the original WordPress filters monitor the data before it is submitted.
This script is written in Perl, not PHP. It was not designed to be an add-on or widget for WordPress. It is a standalone application.
2) Version Release date
————————————
March 25, 2011
3) Requirements
————————————
A server running Perl.
A server having the following Perl modules: WWW::Mechanize, Mail::POP3Client
4) How to install on a server
————————————
1) Transfer the aagwpposter.pl file as ASCII to your web server (make sure it is transferred into a location that can run Perl scripts such as a CGI-BIN).
2) Change the permissions (CHMOD) of the aagwpposter.pl file to 755.
5) How to configure the script
————————————
1) Open the aagwpposter.pl file in a text editor (such as Notepad)
2) Scroll down to the configuration section that is near the top (as shown below)
################################################
# Change your settings below
################################################
#######
# Email/Server settings
#######
my $email_user = ‘secretemail@domain.com’;
my $email_pass = ‘password’;
my $email_server = ‘mail.domain.com’;
my $file_backup = ‘/home/username/public_html/WPbackuplocation’;
my $tag_check = ’1′;
my $server_backup = ’1′;
#######
# Verification email settings
#######
my $path_to_sendmail = ‘/usr/sbin/sendmail’;
my $email = ‘confirmation@email.com’;
my $from_email = ‘noreply@domain.com’;
my $subject = ‘WP post confirmation’;
my $verification = ’1′;
#######
# WordPress settings
#######
my $username = ‘user’;
my $password = ‘password’;
my $url_to_sign_on = ‘http://domain.com/wp-login.php’;
my $post_new = ‘http://domain.com/wp-admin/post-new.php’;
################################################
# Do not make any edits below this line
################################################
3) Edit the required fields as listed in the configuration section.
my $email_user: change this to the user name of the email address you will be sending the emails to so they can get posted. In most cases the username IS the email address itself, sometimes it’s just USER instead of USER@domain.com.
$email_pass: change this to the password of the email account listed above.
$email_server: Determine the email server your email address uses and write it here. Every email host is different.
$file_backup: This is the full folder path to the location on your server where you’ll have file backups saved. You can store files anywhere you have permissions on your server. Remember to create the folder name(s) after you edit the script so the script has a place to write the files!
$tag_check: The only values this can be are 0 or 1. Change it to 0 if you don’t want the script to check each post for proper use of shortcodes or 1 if you want it to make sure posts are written properly. This will ensure that you don’t miss a TITLE tag that makes the rest of the post post improperly. Most people should use 1 as the value.
$server_backup: The only values this can be are 0 or 1. Change it to 0 if you don’t want to record log files of each post the script adds to WordPress for you or 1 if you want backups made. This makes a backup copy of what you submitted in case something happens and it doesn’t post correctly you’ll still have the original post handy.
$path_to_sendmail: Change this to the path of sendmail on the server. The default is the standard location of sendmail but edit it if your location is different.
$email: Change this to the email address you want confirmation emails sent to after the script makes posts to WordPress.
$from_email: Change this to the FROM email address that will be used in the confirmation emails.
$subject: Change this to the email subject line of the confirmation email.
$verification: The only values this can be are 0 or 1. Change it to 0 if you don’t want to receive confirmation emails or 1 if you do.
$username: Change this to the WordPress username you want to post blogs with.
$password: Change this to the password of the WordPress account you want to post blogs with.
$url_to_sign_on: Because WordPress can be installed anywhere on a web server you need to change this to the login form (wp-login.php). In your browser navigate to the WordPress login area and copy and paste the location here. The page should end with wp-login.php.
$post_new: Because WordPress can be installed anywhere on a web server you need to change this to the location of the post-new.php page. In your browser, sign into WordPress and go to the page that allows you to create new posts. It should end with post-new.php. Copy that location directly into here.
4) Create the directory needed to make backups (as mentioned above under $server_backup). This is only necessary if you want to store backups.
6) List of shortcodes
————————————
Start of email [:start]
Post title: [:title]
Post tags: [:tags]
Post category: [:categories]
Post content: [:post]
Post status: [:status]
Post separator: ##########
7) How to use shortcodes
————————————
The only required shortcode is [:post]. The other ones are optional but what good is a blog post without that information? Everyone SHOULD use the [:start] tag but it is not required.
Each shortcode has to be used twice (except [:start] and the post separator) if it is used at all- once as a start tag and once as an end tag. That is to say you wrap the shortcode around the text you are referencing. The start tag and the end tag are identical.
IE: [:title]Hello world, WordPress Remote Poster made this![:title]
The shortcode start and end tags can be on separate lines. For example, the code below will process smoothly:
[:title]Hello world!
Nice to meet you![:title]
You may not nest shortcodes as the results will be entertaining to say the least. For example, the code below should not be used:
[:title] Hello world! [:tags]hello, world[:tags] [:title]
The [:start] tag is special as it tells the script when to start looking at the content of the email. This is to prevent any free email client from placing advertisement text at the top of your emails. It is used only once per email and it should be the very, very top of everything.
There is no [:end] tag because the only data it cares about are within the shortcodes listed above. Once the last [:post] is processed no advertisement text will be included at the end of the post.
The [:status] tag allows you to define how the post gets sent to WordPress. If this tag is left off or is anything BUT [:status]publish[:publish] the post will be posted in DRAFT mode. You must specifically call on PUBLISH for it to go live.
The ########## separator is used when you want to write more than one blog post per email. Just separate each post with the separator and the script will post them separately. You can make as many posts in a single email as you’d like.
Shortcodes don’t have to appear in any order with exception of the [:start] tag. If that is used it has to be at the top or everything above it will get ignored. This means you can use [:post] to add all the content of the blog posting before you outline what the title and tags will be.
** The [:categories] is special and takes a little more human intervention to work. You can only post to 1 category per post (future updates may fix this) and you need to know the category ID number. This is NOT the name of the category itself. You will need to look at the HTML source code of the page where you make new posts to see what number is associated with what category name. The below source code is from Ask-A-Geek.com to show an example.
<ul>
<li id=”category-3″ class=”popular-category”><label class=”selectit”>
<input id=”in-category-3″ type=”checkbox” name=”post_category[]” value=”3″ /> Ask-A-Geek Exclusives</label></li>
</ul>
You will search the HTML for the title of one of your categories, in this example I knew Ask-A-Geek Exclusives what a category name so I searched for that. You see an <input id=”" type=”text” name=”" value=”3″ />
8 ) Examples of how to use the shortcodes
————————————
Example 1: email containing one post
[:start]
[:title]Hello world![:title]
[:tags]hello, world, first post, yay![:tags]
[:categories]1[:categories]
[:status]publish[:publish]
[:post]
this is the coolest thing ever
I posted this with WordPress Remote Poster from Ask-A-Geek.com
[:post]
Example 2: email containing more than one post (notice the start tag used only for the first post)
[:start]
[:title]Hello world![:title]
[:tags]hello, world, first post, yay![:tags]
[:categories]1[:categories]
[:status]publish[:publish]
[:post]
this is the coolest thing ever
I posted this with WordPress Remote Poster from Ask-A-Geek.com
[:post]
##########
[:title]Hello world 2[:title]
[:tags]hello, world, first post, yay![:tags]
[:categories]1[:categories]
[:status]publish[:publish]
[:post]
this is the coolest thing ever
I posted this with WordPress Remote Poster from Ask-A-Geek.com
[:post]
Example 3: basic post with the tags in random order
[:start]
[:status]publish[:publish]
[:tags]hello, world, first post, yay![:tags]
[:categories]1[:categories]
[:post]
this is the coolest thing ever
I posted this with WordPress Remote Poster from Ask-A-Geek.com
[:post]
[:title]Hello world 2[:title]
Example 4: not all shortcodes used
[:start]
[:title]Hello world![:title]
[:post]
this is the coolest thing ever
I posted this with WordPress Remote Poster from Ask-A-Geek.com
[:post]
9) Questions? Problems? Love it?
————————————
Please visit the WordPress Remote Poster page at [here] to ask any questions you may have or just post how much you love it! If you have ideas on how to improve it, please post them there as well.
Been working on getting this set up for the past 8 hours. I think I’m close to finally getting it working. One thing i was curious about was this part fo the script:BEGIN { my $base_module_dir = (-d ‘/home/askageek/perl’ ? ‘/home/askageek/perl’ : ( getpwuid($>) )[7] . ‘/perl/’); unshift @INC, map { $base_module_dir . $_ } @INC;}According to the instructions, we’re not supposed to change that. Is that correct? Also, what is that doing?
Sorry for the confusion. That can be removed or changed based on your web host set up. My host did not originally have a perl module the script needed. All that does is point the script to my host’s module.
Does that help?
Hi
I replied to your post below but I forgot to click REPLY on your post so I don’t know if you’ll get notified.
I also noticed some of my documentation wasn’t showing up properly (html examples not posting properly or smiley faces appearing) so I went through and fixed the documentation! Maybe that’ll help!
Yep, still working with the host, but am almost there.
Most other autoposters don’t do well at posting tags, plus this makes it easy to put into a step with other programs.
Still a no-go. Can you tell me or point me to some information on how the posts get pulled from the email address so I can see if I can do a little trouble shooting.
Hi there.
What exactly isn’t working? Is the script failing to load? Or is it posting stuff you’re not expecting?
If you’re getting an error let me know. If you have a link to it in action that would help, too! If I can’t help you via going back and forth I can try to get it up and running on your server for you. We would have to speak at a later point via PM to discuss login credentials.. OR.. I believe I can remotely host the script on my network for you. I’d still need the credentials for your WordPress configuration to set it up but once it works it’d work forever unless something changes.
Let me know what’s not working and I’ll make sure you get it to work!
Hi,
The posts get to the email account on the server, but they never get posted.
Here’s what’s been done so far:
1. Installed WWW::Mechanize, and Mail::POP3Client via Cpanel
2. Confirmed that perl script will run. Here’s what the host told me:
“There is not a specific directory that any perl script has to go into. As long as it exists within the public_html directory somewhere, it should work just fine. Most people like to organize their executables in a central location(such as the cgi bin).”
3. Confirmed the mail server setting is correct. Here’s what the host told me:
“In regards to the mail server for this domain, mail.yourdomain.com is
correct.”
Note: One thing support also said was this:
“For sending mail, it should go through mail.yourdomain.com on
port 25. If you have trouble with this configuration, exim can be setup to
also listen on port 26. Port 26 would also need to be opened in the firewall.”
4. The following are what are displayed as manual settings for configuring an email application.
Manual Settings
Mail Server Username: username+mydomain.com
Incoming Mail Server: mail.mydomain.com
Incoming Mail Server: (SSL) host.myotherdomain.com
Outgoing Mail Server: mail.mydomain.com (server requires authentication) port 25
Outgoing Mail Server: (SSL) host.myotherdomain.com (server requires authentication) port 465
Supported Incoming Mail Protocols: POP3, POP3S (SSL/TLS), IMAP, IMAPS (SSL/TLS)
Supported Outgoing Mail Protocols: SMTP, SMTPS (SSL/TLS)
I used this plugin to reveal category ids:
http://extend.schloebe.de/script/script/reveal-ids-for-wp-
I used one of my category ids in the test post you supplied:
[:start]
[:title]Hello world![:title]
[:tags]hello, world, first post, yay![:tags]
[:categories]271[:categories]
[:status]publish[:publish]
[:post]
this is the coolest thing ever
I posted this with WordPress Remote Poster from Ask-A-Geek.com
[:post]
I’ve tried the following variations for the username
user@mydomain.com
user+mydomain.com
user
I’d love to just hire you to finish the install. Can you PM me or tell me how to get ahold of you and let me know how much you’d need to get it done?
Thx.
Just wanted to thank you for all your help. It’s been a great learning experience for me. Decided to go with a different solution.
Paul-
No hard feelings. I really would like you to have a working copy of this WordPress script and would be willing to install this for you on your web host at no cost just so you can see how powerful this one is.
If you ever feel like the script you’re currently using isn’t doing what it’s supposed to or doesn’t have all the features you are looking for, shoot me an email at aaron.anderson@ask-a-geek.com with your server information and I’ll set it up for you free of charge!
Good luck!
Aaron, just sent you an email.
Just saw this. Thx, Aaron.