tags:

views:

72

answers:

4

Hi,

I have a basic Drupal install and a bunch of users.

How could my Drupal users receive e-mails from the outside world at their address (e.g. [email protected])?

Thank you!

A: 

Depending on your SMTP server setup (ie Exchange, php.mail, or local mail clients) A good start would be to:

  1. Make sure port 25 is open;
  2. update your php.ini to this

    [mail function] ; For Win32 only. SMTP = smtp.maildomain.com

fergNab
That's how you send emails; the OP was asking about receiving emails.
marcvangend
SMTP is a protocol for sending mail, not receiving. Your instructions will enable sending mail from PHP, not receiving e-mail from the outside world, and are therefore irrelevant and worthy of a downvote.
MaxVT
Even though SMTP is capable of both sending and receiving (see http://en.wikipedia.org/wiki/Smtp), I agree with the downvote.
marcvangend
+2  A: 

Drupal is a system for serving web pages, it does not run mail servers. If there is no mail server present on your system, you will need to install one. Once you have a mail server running, you can install a Drupal module such as Webmail Plus to provide a webmail interface for your users.

marcvangend
Thank you for your comments.I can install a mail server on the machine that's hosting drupal, no problem. I would like to forward the mail to the email address my drupal users have registered with though, not allow them to use drupal as a webmail client.Thank you.
David
In order to do that, I think you would need a Drupal module that adds a forward rule to the mail server config when a user registers or changes his e-mail address. The Drupal-site of that module would not be really hard to write (see hook_user in the api documentation) but I'm not sure which mail server would be easiest to configure from a php script.
marcvangend
+1  A: 

For the case you describe I think the best way to handle this is to set up a mail server with automatic forwarding, and run a batch process once a day or so that extracts the usernames and their e-mail addresses from your Drupal database's user table. Drupal itself doesn't need to be involved in the actual sending and receiving of e-mail at all.

If you are using the Drupal username as the first part of the e-mail address then your export script could just run a query like

SELECT name, mail
FROM  `users` 
WHERE 1 

as part of a shell script that populates a table of e-mail addresses to forward to. For the correct formatting and configuration of such a file you'll really need to dig into the documentation of your e-mail server.

alxp
You could also write a Drupal module that updates the mail server whenever a user is created or their email address is changed.
Greg
A: 

Thanks all!

You've put me in the right direction and I ended up writing a script that reads the Drupal's users table and configures the mail server accordingly. I've turned it into a small Python library for WebFaction, available at http://code.google.com/p/drupal2mail.

Hope it's useful for some!

David