The Particle Lab

Send contact form submissions to Highrise

By Marc, 09 Feb 2010

While adding a few features the back-end of our contact form logic I had an interesting thought; Wouldn't it be nice if these messages not only arrived in our email mailbox, but were also automatically entered into our Highrise account. Highrise is a web-based CRM from 37signals which we use for tracking contacts and project leads.

When the contact form is submitted, we do a little processing (with PHP) and then fire off an email to our contact address as normal. Highrise supports forwarding emails to a 'dropbox' address (more on dropboxes) which will then be imported as a message, creating the original sender as a new contact, or attaching it to an existing one if the email address matches with one of your contacts. All we have to do is add an additional step to reformat the email as a forwarded message, and send it to our dropbox address. Here's the code we use:

$body = "New Contact Form Submission\n\n";

// build message body
/***** <snip> ****/

// sanitise email/name
$name_safe  = mail_header_safe($_POST[&#039;contactName&#039;]);
$email_safe = mail_header_safe($_POST[&#039;email&#039;]);

// send to our contact list
mail($contact_addr, &#039;Contact Form&#039;, $body, "From: $contact_addr\r\nReply-to: \"$name_safe\" < $email_safe>\r\n");

// build highrise body
$new_body  = "\n---------- Forwarded message ----------\n" .
$new_body .= "From: \"$name_safe\" < $email_safe>\n\n";
$new_body .= $body;

// send to highrise
mail($dropbox_addr, &#039;Fwd: Contact Form&#039;, $new_body, "From: $contact_addr");

You will also need to make sure that the from address in these emails ($contact_addr in our code) is registered to a user on your Highrise account, otherwise the message will be discarded by the Highrise importing process. See the Highrise help page for more information on this.

As usual, if you've found this useful or have any improvement please leave a comment!

Photo of Marc Roberts, who wrote this blog post

Marc Roberts is Principal & Co-Founder at Neutron Creations, where he rules over all web development and technical direction. His favourite drink is a sweet manhattan and his favourite sandwich is a croque-monsieur. For a plethora of miscellany follow Marc Roberts on twitter.

comments powered by Disqus