Author Archives: lkeyes70

WordPress: Troubleshooting Contact Forms 2

In our last episode, I determined that the contact form wasn’t working, even on the server that I thought was working. Further investigation, and a several eMails back and forth from Linode tech support yielded the following:

  1. The problem is not the Contact Form 7, it is with the eMail setup on the server where WordPress is installed. (Well there is a  problem with CF7, but we’ll get to that in a minute.)
  2. Linode has a guide for setting up PostFix (the background eMail program). In general, Linode guides are great for any Linux application, whether you are using Linode or not.
  3. To cut to the chase, there were several changes that needed to made.
    1. It looks like PostFix wasn’t completely configured. It was listening on only localhost. To fix this:Update the “inet_interfaces” value to listen on the actual IP address. in the /etc/postfix/main.cf. file  Change this:
      From: inet_interfaces = loopback-only
      To: inet_interfaces = xx.xxx.xxx.xxx, 127.0.0.1

      where xxx.xxx.xxx.xxx is the machine’s IP address.

      – Restart Postfix

      /etc/init.d/postfix restart

      – Verify that everything is working fine

      netstat -tulpn | grep 25  #Verify listening on port 25
      tail -f /var/log/maillog  #See the result of sending an eMail.
  4. The other piece of the puzzle involved editing the Domain Name nameserver records. These are required for Google to accept eMails for delivery, and involve two addtional entries for the domain name.
    1. A reverse name lookup record.
    2. An SPF record.Discussions for both of these items are located at the following links:

      https://www.linode.com/docs/networking/dns/setting-reverse-dns
      https://www.linode.com/docs/networking/dns/introduction-to-dns-records#spf

  5. Finally, the Contact Form CF7 plugin has a setting for the “from” address that is used as the sending address.  Typically, you want this to be something like customerservice@mydomain.com, but the default Contact Form setting actually allows the user to put in their own email address which is then included in the email generated by the form, so that you can simply reply to the email generated by the form. A more secure option (and the option required by Google), is to have the from address be in your own domain.  I just use the same address for both. If you look at the message body field below, you can see that the email address of the person making the inquiry will show up in the body of the message.Contact Setup

WordPress: Troubleshooting Contact Forms

Down the rabbit holeI’m trying to get a contact form working on our WordPress site, and it is a little more complicated than I thought it might be.

The contact form plugin itself in WordPress. We’re using Contact Form 7. Documentation for Contact Form 7 says something to the effect “we’re sending upteen zillion eMails a day, and CF form “just works” for everybody.  Well, kinda, sorta. There are several other issues involved:

  • an MTA (mail transfer agent) which maybe (?)  has to be on the WordPress server
  • the php_mail() function which is part of PHP (the programming language for WordPress)
  • the wp_mail() function which may or may not call the php_mail() function
  • Restrictions on to and from addresses.

I wanted to just run everything through our Google Mail SMTP account, but that seems to add an additional layer.  So first I started with our blog site which is on another server, and tested whether the contact form worked there. It actually doesn’t,  that is, it appears to send mail correctly from the users’s perspective, but no email was received anywhere.

 

Per this note I checked to see if anything was listening on port 25, the usual SMTP port.

$ netstat -tanpl | grep :25
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3030/master
tcp6 0 0 ::1:25 :::* LISTEN 3030/master

$ lsof -i :25
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
master 3030 root 12u IPv4 9667 0t0 TCP localhost:smtp (LISTEN)
master 3030 root 13u IPv6 9668 0t0 TCP ip6-localhost:smtp (LISTEN)

Looks promising.  it appears that both IP4 and IP6 are listening.

So, I created a basic PHP script to test at the server command line, and saved this as testphpmail.php. There are three parameters, the receiver’s address, the subject and the body of the message.

//This is a test of the basic PHP eMail function.

<?php
mail('joeblow@blow.com', "Test PHP Mail", "Test mail from PHP Mail");
?>

Run this script from the command line with the following command:

php -f testmail.php

This worked; I received the eMail. It shows that it comes from root.  At least  I knew that at least the fundamentals are in place on the server.

Checking the mail log,  at /var/log/mail.log I see the following:

$ cat/var/log/mail.log
May 20 14:28:17 li239-124 postfix/pickup[28709]: 11864F123: uid=0 from=<root>
May 20 14:28:17 li239-124 postfix/cleanup[28806]: 11864F123: message-id=<20160520142817.11864F123@localhost>
May 20 14:28:17 li239-124 postfix/qmgr[3039]: 11864F123: from=<root@localhost>, size=351, nrcpt=1 (queue active)
May 20 14:28:17 li239-124 postfix/smtp[28808]: 11864F123: to=<lkkg@myserver.org>,
relay=aspmx.l.google.com[173.194.204.27]:25, delay=0.21, delays=0.01/0.01/0.1/0.09, 
dsn=2.0.0, status=sent (250 2.0.0 OK 1463754497 e92si18328547qga.115 - gsmtp)

So this shows that the message was sent, using root@localhost as the sender’s address and my work eMail as the target.  And indeed, I received this email at work.

I checked the log file at /var/log/mail.log which presented various points of interest…including the fact that we are running the Postfix sendmail email server.  But there is also a status=bounced message for IP6.

$ cat /var/log/mail.log 
May 20 13:50:15 li239-124 postfix/pickup[13030]: 2973DF23B: uid=33 from=<www-data>
May 20 13:50:15 li239-124 postfix/cleanup[14078]: 2973DF23B: message-id=<49922f80371c574883b8b8d699f47d9b@blog.kidsgardening.org>
May 20 13:50:15 li239-124 postfix/qmgr[3039]: 2973DF23B: from=<www-data@localhost>, size=869, nrcpt=1 (queue active)
May 20 13:50:15 li239-124 postfix/smtp[14080]: 2973DF23B: to=<lkkg@myserver.org>, relay=aspmx.l.google.com[2607:f8b0:400d:c08::1a]:25, delay=0.41, delays=0.01/0.01/0.09/0.3, dsn=5.7.1, 
status=bounced (host aspmx.l.google.com[2607:f8b0:400d:c08::1a] said: 550-5.7.1 [2600:3c03::f03c:91ff:fe6e:916c] Our system has detected that this 550-5.7.1 message does not meet IPv6 sending guidelines regarding PTR records 550-5.7.1 and authentication. 
Please review 550-5.7.1 https://support.google.com/mail/?p=ipv6_authentication_error for more 550 5.7.1 information. a139si18154032qkc.140 - gsmtp (in reply to end of DATA command))
May 20 13:50:15 li239-124 postfix/cleanup[14078]: 8DAAAF23C: message-id=<20160520135015.8DAAAF23C@localhost>
May 20 13:50:15 li239-124 postfix/bounce[14081]: 2973DF23B: sender non-delivery notification: 8DAAAF23C
May 20 13:50:15 li239-124 postfix/qmgr[3039]: 8DAAAF23C: from=<>, size=3381, nrcpt=1 (queue active)
May 20 13:50:15 li239-124 postfix/qmgr[3039]: 2973DF23B: removed
May 20 13:50:15 li239-124 postfix/local[14082]: 8DAAAF23C: to=<www-data@localhost>, relay=local, delay=0.01, delays=0/0.01/0/0, dsn=2.0.0, status=sent (delivered to mailbox)
May 20 13:50:15 li239-124 postfix/qmgr[3039]: 8DAAAF23C: removed
root@li239-124:~# dpkg -S 'which sendmail'
dpkg-query: no path found matching pattern *which sendmail*.
root@li239-124:~# netstat -tanpl | grep:25
grep:25: command not found
root@li239-124:~# netstat -tanpl | grep :25
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3030/master
tcp6 0 0 ::1:25 :::* LISTEN 3030/master

Just to be sure, I ran the PHP script again having it send to my home email address which is outside my work domain.  This bounced and I didn’t receive it at the home address.  Now,  in theory, this might not be a bad thing, since all of the Contact Form 7  messages from the blog page should be sent to an address within the same domain, like customerservice@myserver.com.

So far, then we’ve established:

  • PostFix is installed on the blog’s server.
  • Contact Form 7 shows that it is sending message, but the messages are bouncing.  (Hmm…I wonder what I’ve been missing all those times? )

This is so typical of IT. You think you’re troubleshooting an issue on one server, and upon investigating the same issue on another server that you think is working…you find that it isn’t and down the rabbit hole you go!

FileMaker 15

filemaker

FileMaker has updated to version 15 for all platforms. This version includes a ton of bug fixes, heightened security, and some internal changes, as opposed to visual changes. In fact it almost looks and acts the same as version 14.

There is a fair amount of grousing going on in the FileMaker forums about the paucity of new features and (yet another) increase in the effective price. I’m afraid that FileMaker is pricing themselves completely out of the low-end market, although a single copy can be had for education or nonprofits for $197 on Amazon. (Regular price $329).  This is a perfectly respectable deal, and you might want to consider at least one copy for end-user database needs especially if you use Macs, or loath Microsoft Access. FileMaker is my database of choice for front-ends for mySQL (via ODBC), managing eMail lists, and creating tables and inspecting data of all kinds.

FileMaker comes with some pre-built database applications called “Starter Solutions”. Some of these  have been updated for version 15.  I did my expense reporting for a recent trip in the Expense solution, and it makes an attractive listing sorted by categories of all your trip expenses.  Here’s the data entry screen.

Screenshot_051716_035903_PM

Here’s the report:

Expense Report

The application can be hosted on FileMaker server and accessed in a web browser, or run within a standalone copy of FileMaker on a Mac or PC, or run on an iPhone or iPad using the free FileMaker Go app.

There is provision for storing an image of each receipt.  If you run the application on an iPad, you can snap a picture of a paper receipt, or enter a bar-code.  Pretty slick!

 

WordPress Woes and .htaccess

After spending months working on our new WordPress site hosted at Linode, we were ready to flip the DNS from xxx.xxx.xxx.xxx to a realdomainname.org.

Not so fast!” said the SEO expert… “you need to have your 301s in place.” So, we went through the drill and identified the top 100 pages on the old site. These were pages that had been visited in the previous month or so, and also ones that we knew were especially popular. We then created an .htaccess file, which is a file containing instructions for any visitor who arrives at the new site via a search on an old URL from the old site.   Here’s a snippet of what it looks like to start.

# LK 5/2/2016 
Options +FollowSymLinks
RewriteEngine on
Redirect 301 /node/96821 http://www.realdomainname.org/toolbox/
Redirect 301 /node/120 http://www.realdomainname.org/designing/
Redirect 301 /node/2 http://www.realdomainname.org/
Redirect 301 /node/11522 http://www.realdomainname.org/basics/
Redirect 301 /node/13152 http://www.realdomainname.org/toolbox/
Redirect 301 /node/12931 http://www.realdomainname.org/activities/

So far so good. Except this is ass-backwards. We should have worked out the WordPress URLs before creating the .htaccess file because WordPress itself has something to say about the contents of the .htaccess file, viz:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

These entries in the WordPress file are created based on a WordPress setting under Settings->Permalinks which allow you to change what shows as a URL for access. You can choose among a number of options including having the blog post title in the URL as well as the post’s category. (another reason for assigning a post to only one category).

One you have saved the permalinks setting, WordPress will write to your .htaccess file. If this is the first time, you will see that the .htaccess file contains lines similar to those in the # BEGIN WordPress block above.  Otherwise, my guess is that WordPress rewrites the block to accommodate how you want the permalinks to appear.

Other issues:

Note the lines

<IfModule mod_rewrite.c>
RewriteEngine On

refer to an Apache web site module called mod_rewrite. This is a piece of code in the the Apache web server which accomodates the rewriting of URLS.  So, for example, maybe you have a post that is physically located at:

 /var/www/html/wordpress/wp-content/posts/mylovelypost.html

A default URL for a blog post might look something like:

http://www.realdomainname.com/index.php/wp-content/mylovelypost/

However, after implementing your pretty permalinks it will automatically reset itself to

http://www.realdomainname.com/mylovelypsost/

or even

http://www.realdomainname.com/mylovelycategory-mylovelypost/

if you choose to include a category.in the URL formula. This “virtual” URL is the one that gets indexed by the search engines, and so is worth giving some serious thought so that you get it right the first time.

Note that this whole exercise is possible only on self-hosted WordPress sites, not on sites hosted at WordPress.com. So, at this writing, the techfornoprofits.com  site is hosted at WordPress.com, and so URLs are fixed using the formula of http://site+year+month+day+blog_post_title.

https://techfornonprofits.com/2016/04/12/ten-ways-to-improve-a-grant-application/

So, having gotten the permalinks thing squared away, I then added the 301 redirects to the .htaccess file.  These are in the  format of:

Redirect 301 /node/96821 http://www.realdomainname.org/toolbox/

Statement = Redirect 301
Old site page name
New site address.

The /node/96821 address for the old site page is a convention from Drupal. (Drupal is another content management system. Our new WordPress site is  a conversion from a Drupal 6.7 site).

Two notes regarding the .htaccess file:

  1. The .htaccess file is normally a hidden file, so it isn’t visible within a normal directory listing. There is a setting in FileZilla which permanently “show hidden files”  If the file name is prefixed with a period, it is considered a “hidden” file.
    .
  2. Once the .htaccess file has been created the best practice is to turn off the ability for it to be written to by changing the file permissions. Conversely, if you either don’t see any changes or get an error message when attempting to adjust the Settings-Permalinks in WordPress….the .htaccess may either be non-existent, or flagged as read-only. WordPress has to be able to write changes to the .htaccess file.

At this point the permalinks are squared away, and the 301 redirects are in place. But our woes are just beginning!

Nonprofit CRM Overview

NonProfitCRMIn designing our non-profit CRM, we have been looking at all of the functions that we’d like to track.  At a minimum, we think each of the entities above will use one database table. In practice each entity will have an associated “interaction” table and “look-up” tables that feed picklists of options.

A little background. Our organization makes grants to schools and community groups. Many of these grants are funded through commercial sponsors, or through philanthropic individuals or organizations. Thus we have both Grant Prospecting and Grant Application Management functions.

Grant Prospecting — This is us prospecting and managing the workflow involved in applying for a grant. Recently when it gets  down to the application process itself  we have we have worked in Slack.

Grant Application Management — As we receive grant applications we have to process them and eventually evaluate them. We currently use LimeSurvey for our online grant application.

Sponsor Prospecting — If we don’t have an individual or foundation donor, we may fund a program through a sponsor; a company that wants to promote their community engagement or charitable contributions.

Contact Management — The contact table part of our design includes all the usual information about contacting a person In our database design, this may actually turn out to be  a hidden many to many table. One of the objectives that I want to address is the ability to look at a single person’s contact information and determine what our relationship(s) are with that person. A person could be a donor, a member, a volunteer, a member of our board, member of our advisory board. and our lawyer. This is really what CRM is all about, as well as the ability to track the relationship steps with the person at any stage of the relationship.

Membership (Donor) Management. We used to do this in Little Green Light. We’re not sure our business model going forward lends itself to membership.. but if it does, this is where we’d like to track members.

Media / Outreach Lists — We have 3782 media contacts to which we send press releases etc.

Admin — Could we provide forms for our usual HR functions like time sheets, vacation accrual, expense reimbursement, travel schedules, etc?

Note that this design exercise is independent of any particular kind of software. We have bits of data scattered in spreadsheets, word-processing files, online applications such as LimeSurvey and Little Green Light, FileMaker databases and of course eMail.

Update: I’ve added two additional tables; one for “contacts” (which will feed its contact and address data to the other tables), and  “projects” table which contains data about each project.

 

 

 

Ten Ways to Improve A Grant Application

Odds and Sods

Random Tips

  • Panic in the ranks! This is not the first thing you want your users to see in the morning as they attempt to log into to complete a grant application:
    The table "{{settings_global}}" for active record 
    class "SettingGlobal" cannot be found in the database."

    After some poking around it turns out we were out of allocated disk space on the Linode.  df -m showed 100%. I think this was related to a backup and restore that I had done a day earlier; which preserved the old image as it copied a new version  to the same allocated disk space. The actual error was returned by LimeSurvey, which was reacting to a system 8 error generated by mySQL.

  • Trying to see the analytics for a bit.ly link?  Just append a plus sign ‘+’ to the link. This will show the statistics for the link instead of what the link points to.

Stuff I’d Like to Try Out

Two “glue” programs that process something in one program, based on a trigger that is set in another program.

Two forms program that make web forms.

Links of Interest

50 tools for project management. (from Zapier)

SalesForce: Donors and Donations

Looking into this further,  the SalesForce non-profit starter pack deals with Donors and Donations.

A typical issue when dealing with donors is that you often want to track relationships between different donors; for example spouses in the same household who contribute independently to your organization. One way of doing this (not just in SalesForce) is the notion of a household.  In database terms, a household would represent many-to-one relationship where a one or more contacts are members of a single household.

SalesForce will accommodate no less than 4 different kinds of contact/account models. The details are explained in their FAQ about account models.  The upshot is that out of the box, the most recent version of their non-profit starter pack uses what they call their household model.

SalesForcehohousehold

If you check out the terminology in the diagram above, you can see that they are mapping non-profit terminology to their sales terminology.

Non-Profit SalesForce
Donor Contact
Household Account
Donation Opportunity

We’ll have to look at this when it is wired up as a online form.

SalesForce NonProfit Starter Pack

We’ve been looking into a Customer Relationship Management system for our nonprofit, that will encompass more than the just the usual fundraising type of database. One option that we’re taking a hard look at is the cloud-based SalesForce nonprofit version. One of the tasks is to learn the workflow jargon such as:

  • Opportunity Stages
  • Opportunity Sales Processes
  • Opportunity Record Types

Salesforce provides a donation for up to 10 users for any qualifying non-profit organization. The Nonprofit Starter Pack is a pre-configured set of functions and data elements that can be overlaid on to a “standard” SalesForce company installation. The donation includes significant online support, documentation,  and forums with members from nonprofits who are using the system.

As a preliminary exercise, I’m going to attempt to import our donor data from our previous Little Green Light system. This consists of two tables; a donor contact table and a transaction table which lists all of the donations made by members in the donor table. Both of these are currently living in FileMaker which can export into a variety of file formats including Excel and comma delimited (text) files.

WordPress: Fix the File Upload Size Limit

On our WordPress site we want to allow the site manager the ability to upload PDF files which can then be downloaded by our blog viewers. While working out this process we ran into a problem with the file size; any file larger than 2 megabytes was not allowed to be uploaded to the site.

Rather than having this setting located somewhere within WordPress, it turns out that the setting is set by the PHP installation.  (PHP is the language that WordPress is written in, and WordPress the application is written as a series of PHP files).

As I was working through this issue, the first embarrassment was that I couldn’t even find the WordPress installation on my Linux server. Usually WordPress is supposed to be installed somewhere relatively transparent, like the /var/html/wordpress folder. Instead mine was buried under  /srv/www/li999-999.members.linode.com/public_html; somehow related to my virtual host from Linode

As my plumber says, when looking at the latest plumbing problem in our basement, “I wonder why they did that?”  Whatever. The way I finally found this out was to search for the one file that is in every WordPress site; wp-config.php.  I did this by firing up the FileZilla FTP program, and doing a search for remote files.

SearchRemoe

Having found the root directory of my WP installation,  I now needed to find the location of the PHP configuration file. I used a similar search in FileZilla and came up with two php.ini files.  Which was the “real” one?

Actually, I didn’t need to do that. Instead, I needed to get to have a script that calls the phpinfo() function which displays a nice list of all the php configuration parameters. Placed in the root directory of my web server, and then called from a web browser, this script displays all of the inner workings of the php configuration of my site.  Here’s the script:

<?php
// Show all information, defaults to INFO_ALL
phpinfo();

?>

This script is saved as GetPHPInfo.php and copied back to the root directory of the web server.

http://mywebsite/GetPHPInfo.php

Call this script in the web browser and it produces  the following:

PHP1

The above is just the tip of the iceberg. Scrolling waaaay down, I find the following parameter in the “core” section of the page:

php2

That is the size restriction, and it is this parameter that I need to change.  I’m thinking that 12 megs should be plenty.  Looking back up top in the 6th line, I see the “Loaded Configuration File” is located at:  /etc/php5/apache2/php.ini  This is the file I’m going to change. So, its back to FileZilla to find it, download it and edit it in Notepad++

PHPini

I downloaded the wp-config.php file to my local machine using FileZilla.  Then I edited the file using Notepad++. to change the  2M to 12M.  Then I uploaded the file via FileZilla back to the web server.

At this point I needed to reboot the web server, Apache2. Depending on the your installation, there are a couple ways to do this at the command line:

$ sudo /etc/init.d/apache2 restart

Or,  in the case of the lazy systems administrator, I just rebooted the whole server. This takes less than two minutes.

The result is now we can upload files that are a maximum of 12 megabytes in size.

I get to do this on another WordPress server too.  Oh joy!