Send contact form submissions to Highrise

Written by Marc on 09.02.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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$body = "New Contact Form Submission\n\n";

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

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

// send to our contact list
mail($contact_addr, 'Contact Form', $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, 'Fwd: Contact Form', $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, 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 hazelnut latte and his favourite sandwich is a croque-monsieur. Follow him on Twitter: @marcroberts.

4 Responses

  1. Kushal Pisavadia

    February 9th 2010 @ 2:57 pm #

    The Highrise dropbox is unbelievably useful, but I’m just curious why you didn’t wrap all of this up into one mail() call and just BCC the dropbox account?

  2. Ben

    February 9th 2010 @ 3:10 pm #

    @Kushal – An excellent question. We’re defensively avoiding spoofing the “from” header as being from the original sender, so as to avoid tripping any excessively zealous spam-filters. If we were to BCC the dropbox on our original mail, Highrise wouldn’t know who originally sent the email. Also, Highrise looks for the ” — forwarded message — ” line, and we don’t want that in the mail that comes to us.

  3. Yaron Schoen

    February 9th 2010 @ 3:28 pm #

    This is such a good idea! I have been putting these requests manually in Highrise and was always wondering how I can make this more efficient.

    I was gonna ask the same about the BCC, but what you said Ben makes total sense. You know how much I hate spam ;)

    I may just use this for my form as well…

  4. Kendall

    February 12th 2010 @ 9:32 pm #

    That would be extremely useful, thanks for the idea!

Leave a Reply


(Never published)


© 2010 Neutron Creations Ltd. Registered in England #6734162.

Say: hello@neutroncreations.com