I wrote a simple contact module and installed it here on drupal.org. The module lets people contact each other via e-mail without giving away the recepient's e-mail address. Note that this feature is only available to registered users. As can be seen, each user's profile page now has a 'contact'-tab. The actual contact form will only be present if the user has chosen to accept e-mails sent through drupal.org. This feature is disabled by default and can be enabled by checking the Personal contact form checkbox on your account's settings page.

We believe this feature will help improve communication, especially once project maintainers enable this feature. Expect more changes to improve collaboration and communication in the next few weeks. Suggestions welcome.

Comments

cel4145’s picture

if so, I'd like to try it on some of the sites I'm running.

dries’s picture

The module is not available yet: it is a work in progress. If you want, I can send you a copy. Drop me an e-mail.

arnabdotorg’s picture

....I can contact myself. Is that intentional?

dries’s picture

It can be handy to help decide whether you want to enable the contact form or not.

Dublin Drupaller’s picture

Have tried sending you a contact email requesting a copy of the personal contact module to try out....not sure if the mail is getting through to you.

Jason

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate

Tarlbot’s picture

The form implies that your (secret) email address shows. However in the description above it says that it will now show. One of the two places needs to be changed.

dries’s picture

I don't understand what you are saying. Can you elaborate?

Tarlbot’s picture

If I go to page:

http://drupal.org/user/1/contact

It says:

From:
Tarlbot <my_real_email@address.com>
To:
Dries 

which implies to me that my_real_email@address.com will show to you (Dries) when you read it.

moshe weitzman’s picture

as well it should drupal does not intend to give you a way to anonymously flame another user. your email address will rightfuly be exposed. thats the intent.

Tarlbot’s picture

on the user page:

 E-mail address:*
Insert a valid e-mail address. All e-mails from the system will be sent to this
 address. The e-mail address is not made public and will only be used if 
you wish to receive a new password or wish to receive certain news or 
notifications by e-mail.

Maybe this needs to be changed so people know that if they send an email from the site then their email address will become public.

The other thing that may be important is it should be very clear to users that this is an email form, not a "Private Messages" and if they want to keep their email secret they will have to use that other function if it is available.

It may be very difficult to explain the difference between Private Messages and emails.

gábor hojtsy’s picture

Isn't it clear enough that your email address used to send the email is shown on the contact form clearly as the from address?

zaur1945’s picture

I did the same on my 2 other websites
http://www.qamanagement.co.uk
and
http://www.localareaflorist.com

Steven’s picture

The recipient's email address is hidden, not that of the sender. Otherwise there is no way to contact the sender. The recipient will of course need to send an email back to reply, at that point the addresses are no longer secret.

mousse-man’s picture

And if drupal just uses the address to send forth the new user registrations and then gives a URL in the mail the user can click to reply? This way, just the user name at the site is known, and not his email address, which can prove very handy in some cases.

Steven’s picture

It is not our intention to host email for all Drupal enthousiasts this way. The current method is a good compromise between privacy and ease of use.

mousse-man’s picture

No, just have a URL in the mail the user can click to reply to the sender via Drupal functionality. No SMTP involved here...

gábor hojtsy’s picture

Once again, you are talking about privatemsg, which is a different functionality.

media girl’s picture

Perhaps a solution would be to add to the subscription.module the option for users to subscribe to PMs, so they can receive email notification that they received a private message. That way nobody's email is revealed.

--
mediagirl.org

boris mann’s picture

You get email notification of privatemsg today, without needing subscription module.

benshell’s picture

I made a contact form for my website, http://www.saccf.com/contact, that accomplishes a similar goal, but instead of linking the form to user profiles it is a separate page with a drop-down list of all users. I guess this wouldn't work well on a large site like Drupal.org (the list would be too long), but for smaller sites it's a nice way to allow anyone (even unregistered users) to contact others without knowing their email address. My code isn't as modular as it should be, but if anyone is interested in this I can post the code somewhere and maybe even get back to improving this module.

NickHBO’s picture

I tried to use the Contact tab but you have email contacts disabled :o

I am very interested in the module you have on your site and have a few ways I think it could be improved. So now you know I'm interested, I'll just jump right into a prioritized list of some features I'd love to see :D

  1. The ability to specify certain members on the list via the admin panel - this way only the developers or leaders will be on the contact list. You could still leave the option to have everybody on the list but adding this feature would make the module more appropriate for very large sites.
  2. The ability to assign self-contained groups via the admin panel to go on the drop down, including weighting the items. I noticed how you have several groups on your drop down, I assume this is created from the user groups people are placed into. It would be nice to be able to break people down into smaller groups / titles without having to create entire user groups for those people. For example "Project Lead", "Programmers", "Artists", etc could all be in the members group but as far as your module is concerned they fall under those three separate categories.
  3. An area above the "To:" box that could be defined in the admin panel as a sort of "read before you send" message to users.

That about covers it for my ideas, not too many things but still some additions that could greatly improve the module's functionality. Please let me know what you think and if you'll be able to pump out your module with these features :)

Nick

firedancer5’s picture

I might be interested in this. I am trying to set up a system that allows users to email a user via a post. I was going to use the privatemsg module but I am having some issues getting links to show up on each post.

Would it be difficult to allows users a link to this contact page from every post and then pass in the post's user id so that it will email that specific user? So if you see a post and want to contact user you:

1.) click a link to "contact post's author"
2.) go to the contact form and fill in a message
3.) the click submit and the post's author gets a email sent to them.

Would that be difficult to do with your code?

tostinni’s picture

I suggest you post a support request here.
Btw to achieve this, you just need to tweak your theme.
If you're using phptemplate, just modify node.tpl.php to add this

     <span class="submitted"><?php   if ($node->type == 'page'):
print t('contact post\'s author : ').l($node->name, 'user/'.$node->uid.'/contact')

else:

print $submitted;

endif;
?> instead of

     <span class="submitted"><?php print $submitted; 


?>
This way if it's a page (you can drop the if else clause to get it working for all kind of node) it will dispay the "write to author" link.
Also se this code snipet.

firedancer5’s picture

Thanks that makes sense to me. I just cannot seem to find the node.tpl.php file you mentioned. Is this a standard install template?
I see only node.module.

sepeck’s picture

In the developers guide there is a theme dev guide. Look at the phptemplate based section.

-sp
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

tostinni’s picture

This apply to 4.7 that use the phpTemplate theme engine, so I guess you should wait a little for it to be released or install it from the project section.

Also, please post an issue, this is not the place for such demand. Imagine someone would like to do the same latter, it will be very hard to find your post as your demand has nothing to see wih hread subject.

jose reyero’s picture

Hey, I like it... I want it... hope it will be available soon

Just an idea. Why to you show the "Contact" tab for a user when contact option is disabled? It would save a click.

sgroup’s picture

Could this work - Instead of showing the senders real e-mail address, show something like this: from_user_name@thesite.com. If the message was replied-to, when the mail came in it would be forwarded to the address associated with the user name. The from address in that message would be in the same format.

sepeck’s picture

If you the user are sending an email to a developer about whatever, you should not be able to remain anonymous. You are trying to establish communications with someone. If I take the 'risk' of allowing people to contact me, then you should accept that I can reply to your question.

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

sgroup’s picture

Sorry - your comment is right on when operating in the Drupal dev forum.

I'm working with a group that wants to have easy communication among themselves using their User Name (real name) but they want to hide their "home" e-mail addresses at all times. The intent is to remove any opportunity for this information to get forwarded to anyone outside the group. And to keep everyone off the spammers radar.

tostinni’s picture

So you just need Private Messages, not email form contact ;)

tag-1’s picture

Many large sites use a standard contact form in which you fill in your own email -- a requirement, as many large (non shopping or community) sites don't have or require accounts. For example:

http://wired.com/news/feedback/mail/1,2330,0-1291-66310,00.html

I wonder if these ever get spammed? Probably not worth the effort (then again...). It is nice to have the option of sending a comment without registering though - I'd guess it increases the number of mailed comments pretty significantly.

A99-1’s picture

By which I mean that my own idea deviates slightly from your current implementation. Nothing fancy mind, yet imminently workable.

What I had in mind for my http://A99.org/ Dutch Drupal site is to have it function as an automated UNIX .forward system. For those who'll opt-in to that functionality, naturally.

Since a couple of years I've been running postfix -- Snapshot-20010502, to be updated Real Soon Now -- which can handle, as can other MTAs, MySQL based forwarding. I am presuming that Drupal keeps the mail adres given around, just in case.

Then all that would be needed would be to send whatever mail out with sender address DrupalSiteUsername@DrupalSite.domain and to have the MTA forward bidirectionally. Doing stuff thataway each person will be reachable without giving up their own, cherished, and very, very personal email address.

You can then also tack on other options from virus scanning, pattern or bayesian based spam filtering, as well as RBL handling and stuff. Especially since I've yet to come around to implementing white list functionality.

There's also some really good sounding utilities for MTAs that will tack on a timecode and will provide a timed window of response opportunity before invalidating that adjusted sender address. All kinds of neat stuff out there.

Just needs to be tied together :).

The reason I haven't done so already will become clear from studying my MSinfo site. Sure, it's dutch based. But both anglons and saxons, as in anglo-saxon, where germanic races that went through the Netherlands (then still Frisia) to concur Brittany. And thus crossed Mare Frisicum as it was then called by the Romans.

IOW, it's all Greek to me anyway. :)

Anyhow, this is what I've been thinking off. And which, if it weren't for this dratted illness, I would have at least tried to implement allready. But then, such is life.

Roelof

PS The one I had in mind was Tagged Message Delivery Agent (TMDA) which looks quite sturdy to me.

PPS There might also be call to add an inner-trust option where site colleagues can mail one another without being subjected to the challenge rigmarole.

dandaman’s picture

Dries,

I'm enjoying this Drupal thing and really getting into it. However, for my needs, I was thinking of a simple addition to this great module. Here's what I think it should have:

There should be an option so that anonymous users can just type in their e-mail and leave comments. For example, I'm redoing a website with Drupal and I currently have created a contact form. Nobody's really going to know it's a Drupal site, the only thing is that I and the people who I am designing the website will have accounts where they can edit portions of the site. So, in my case, it would be nice to have all of the users (or a class of users) available to be contacted via the form.

Could that be included in future releases of the module? It seems like a fairly easy change and I might even take a crack at editing your module, I guess. (It will be my first time editing, but I have to start sometime, for sure.)

Dan "da Man"
Webmaster
http://cMusicWeb.com/
http://da-Man.com/

Dan "da Man" Ficker
http://da-Man.com/

Steven’s picture

Anonymous users are not allowed to email because of spamming reasons. It would be very easy to abuse this feature.

Still, adding it should be pretty easy. You just edit the module's page hook to ask for an e-mail address when not logged in.

--
If you have a problem, please search before posting a question.

dandaman’s picture

Thanks for the info. I'll work on it. I thin kit would possibly be worth putting in as an option, although with it should come a hefty warning saying what could happen. On the other hand, there are probably a number of other websites that use Drupal as mostly a backend and the number of users is just the maintainers of the website, and contacting could be very useful.

Dan "da Man"
Webmaster
http://cMusicWeb.com/
http://da-Man.com/

Dan "da Man" Ficker
http://da-Man.com/

jsimonis’s picture

Just how would one go about doing that? I don't want to break the module or anything. On some of my sites only the maintainers of the sites are allowed log-ins. It would be great to have it set so that people could easily contact you. We already get a lot of spam from our addresses showing on the site (even when we do stuff to modify the address). So this probably wouldn't make the spam problem any worse.

It'd also be nice to be able to set the contact form option to default to on rather than off. I know a lot of people never look at their account settings page after they register.

Thanks!

This is a great module, by the way.

--
Jenni S.

s0nic’s picture

Just for the few that have wondered on how to modify this module. It is a fully-working example on how to do this, and I havent seen a bug (only tested it for a few times).

What does it do? If you are registered (and logged in), there will be no difference. But if you arent, two new input fields will show up asking your name and email. Both fields are required to successfully submit the form.

A few things worth to mention:
- Check for valid email adresses dont work for non-users (dont know how to do this)
- flood control dont work for non-users (easy to set up if needed)
- mails from non-users will have the email adress instead of an URL to the profile
- for non-users watchdog will show the given name instead of the users name

Now the code:

// $Id: contact.module,v 1.6.2.2 2005-08-17 00:56:13 unconed Exp $

/**
 * @file
 * Enables the use of personal contact forms.
 */

// Users are not allowed to send more than x mails/hour:
define('CONTACT_HOURLY_THRESHOLD', 3);

/**
 * Implementation of hook_help().
 */
function contact_help($section) {
  switch ($section) {
    case 'admin/modules#description':
      return t('Enables the use of personal contact forms.');
  }
}

/**
 * Implementation of hook_menu().
 */
function contact_menu($may_cache) {
  global $user;
  $items = array();

  if (!$may_cache) {
    if (arg(0) == 'user' && is_numeric(arg(1))) {
      $items[] = array('path' => "user/". arg(1) ."/contact", 'title' => t('contact'),
        'callback' => 'contact_mail_user', 'type' => MENU_LOCAL_TASK, 'weight' => 2);
    }
  }

  return $items;
}

/**
 * Implementation of hook_user().
 *
 * Provides signature customization for the user's comments.
 */
function contact_user($type, $edit, &$user, $category = NULL) {
  if ($type == 'form' && $category == 'account') {
    return array(array('title' => t('Contact settings'), 'data' => form_checkbox(t('Personal contact form'), 'contact', 1, $edit['contact'], t('Allow other users to contact you by e-mail via <a href="%url">your personal contact form</a>. Note that your e-mail address is not made public and that privileged users such as site administrators are able to contact you even if you choose not to enable this feature.', array('%url' => url("user/$user->uid/contact")))), 'weight' => 2));
  }
  if ($type == 'validate') {
    return array('contact' => $edit['contact']);
  }
}

function contact_mail_user() {
  global $user;

  if ($account = user_load(array('uid' => arg(1), 'status' => 1))) {
    if (!$account->contact && !user_access('administer users')) {
      $output = t('%name is not accepting e-mails.', array('%name' => $account->name));
    }
    /*
    else if (!$user->uid) {
      $output = t('Please <a href="%login">login</a> or <a href="%register">register</a> to send %name a message.', array('%login' => url('user/login'), '%register' => url('user/register'), '%name' => $account->name));
    }
    */    
    else if (!valid_email_address($user->mail) && $user->uid) {
      $output = t('You need to provide a valid e-mail address to contact other users. Please edit your <a href="%url">user information</a>.', array('%url' => url("user/$user->uid/edit")));
    }

    else if (!flood_is_allowed('contact', CONTACT_HOURLY_THRESHOLD) && $user->uid) {
      $output = t("You can't contact more than %number users per hour. Please try again later.", array('%number' => CONTACT_HOURLY_THRESHOLD));
    }
    else {
      $edit = $_POST['edit'];

      if ($edit) {
        // Validate the message:
        if (!$edit['email'] && !$user->uid) {
          form_set_error('email', t('You must enter a mail adress.'));
          form_set_error('name', t('You must enter your name.'));
        }
        if (!$edit['message']) {
          form_set_error('message', t('You must enter a message.'));
        }
        if (!$edit['subject']) {
          form_set_error('subject', t('You must enter a subject.'));
        }

        if (!form_get_errors()) {
          $mtpl = array();
          if (!$user->uid) {
            $mtpl['name']      = $edit['name'];
            $mtpl['name-url']  = $edit['email'];  
          }
          else {
            $mtpl['name']      = $user->name;
            $mtpl['name-url']  = url("user/$user->uid", NULL, NULL, TRUE); 
          }

          // Compose the body:
          $message[] = "$account->name,";
          $message[] = t("%name (%name-url) has sent you a message via your contact form (%form-url) at %site.", array('%name' => $mtpl['name'], '%name-url' => $mtpl['name-url'], '%form-url' => url($_GET['q'], NULL, NULL, TRUE), '%site' => variable_get('site_name', 'drupal')));
          $message[] = t("If you don't want to receive such e-mails, you can change your settings at %url.", array('%url' => url("user/$account->uid", NULL, NULL, TRUE)));
          $message[] = t('Message:');
          $message[] = $edit['message'];

          // Tidy up the body:
          foreach ($message as $key => $value) {
            $message[$key] = wordwrap($value);
          }

          // Prepare all fields:
          $to = $account->mail;
          if(!$user->uid)
            $from = $edit['email'];
          else
            $from = $user->mail;
          
          // Format the subject:
          $subject = '['. variable_get('site_name', 'drupal') .'] '. $edit['subject'];

          // Prepare the body:
          $body = implode("\n\n", $message);

          // Send the e-mail:
          user_mail($to, $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");

          // Log the operation:
          flood_register_event('contact');
          watchdog('mail', t('%name-from sent %name-to an e-mail.', array('%name-from' => $mtpl['name'], '%name-to' => $account->name)));

          // Set a status message:
          drupal_set_message(t('Your message has been sent.'));

          // Jump to the user's profile page:
          drupal_goto("user/$account->uid");
        }
      }
      else {
        $edit['mail'] = $user->mail;
      }
      
      $output  = '';
      
      // show input field for email only if user is not logged in
      if(!$user->uid){
        $output .= form_textfield(t('Name'), 'name', $edit['name'], 50, 50, NULL, NULL, TRUE);
        $output .= form_textfield(t('E-Mail'), 'email', $edit['email'], 50, 50, NULL, NULL, TRUE);
      }
      else {
        $output .= form_item(t('From'), $user->name .' &lt;'. $user->mail .'&gt;');
      }
      $output .= form_item(t('To'), $account->name);
      $output .= form_textfield(t('Subject'), 'subject', $edit['subject'], 50, 50, NULL, NULL, TRUE);
      $output .= form_textarea(t('Message'), 'message', $edit['message'], 70, 8, NULL, NULL, TRUE);
      $output .= form_submit(t('Send e-mail'));
      $output  = form($output);
    }

    print theme('page', $output, $account->name);
  }
  else {
    drupal_not_found();
  }
}

dtabach’s picture

I've been longing for this functionality, right the way you describe it. I totally agree the sender's email should be visible to the recipient, and the recipient's email remains hidden (until, and if, he decides to reply to the original message).
Do you have a 4.5.x version of this module? I could not find it anywhere in the site.
Thanks

Durval Tabach
(drupal newbie at archiclube.org)

Durval Tabach

Patrick Nelson’s picture

Am currently using 4.6.3 but am playing around with the CVS version of the Contact module and I have a couple of questions, if anyone has the time.

1) The site-wide contact form that was added in version 1.8 references a database table called contact. I've located this table in the database.mysql file in version 4.6.3 but there are also references to a field in that table (subject) which doesn't exist in the Create Table MySQL statement. Can anyone tell me where to get the up-to-date table from?

2) Should it be possible to send emails using this format that contain HTML? I ask because, well, because I can't.

Appreciate any help that is forthcoming.

Regards

Patrick

tostinni’s picture

This is an announce thread, if your looking for support, please open an issue.

Patrick Nelson’s picture

tostinni,

Sorry about that - I just didn't think. Having one of those days... will re-post in right place.

Patrick

Fransie’s picture

This is exactly something we want for our site! The module is not listed in the list of modules (4.5, 4.6 or cvs). The 'contact directory' module is something else, isn't it? Is a version of the work in progress available for download somewhere?

Frans

behindthepage’s picture

Go to admin/modules and enable "contact" module.

gpdinoz
"If we can see further it is because we stand on the shoulders of giants"

Regards
Geoff

phranque27’s picture

I tried to hack this module, knowing almost nothing about PHP, and (surprise!) I blew it.

I need to modify contacts.module so that it can be used by non-registered users. Why? on my site, users are writers who are using the site to share their work with the public, so they need to be able to be contacted by the potential publishers, etc. without making their email address available to bots.

So I went and hacked contacts.module so it would be accessible to non-registered users. Then I had the bright idea to try and replace the "From" and "To" sections with textfields so that visitors could fill them in.

Well, that screwed something up. I sent a test email to myself, and now I'm getting test emails every 15 minutes even AFTER I deleted contacts.module from the system! I've created a monster and it's coming after me! :)

Can someone please help?

Thanks!

bandelier’s picture

Wondering if someone could tell me where the trigger for allowing personal contact forms for each user is in the mysql tables. I need to do a batch update to allow all users to have this functionality vs. going thru each user individually