By therobyouknow on
I want to use additional profile information fields - email and password to send to a webmail server to log in to webmail for a user.
I've looked at the mail modules but none seem to quite do what I want.
I've looked at how to setup extra profile variables here
http://drupal.org/handbook/modules/profile
But it says nothing about the correct way to access the variables when writing PHP code.
Please advise.
Comments
Here's my solution to my own problem
I always like to find a solution to my own problem - so here goes:
How to provide automatic login/single-sign-in to POP3/webmail when logging into your drupal site.
This code is for a drupal theme block which will provide a button to auto-sign into email once logged into your drupal site.
You need to create 2 new user profile fields profile_yourdomain_email (use only text before the @ for this field e.g. first.last@yourdomain.com just use first.last in this field) an profile_yourdomain_email_password.
The code assumes that your webmail system can be logged into via the http form post cgi method.
It also assumes the following fields in the posted form data.
- username
- password
- pop3host e.g. yourdomain.com
- mailserver e.g. yourdomain.com
and other fields may/may not be required by your isp host
-login type (e.g. simple - standard off the shelf webmail systems like @mail offer different ui skins - for example, simple)
-mailtype e.g. pop3
the disadvantage of this code is security, as the code fetches over the network standard via plain text http the password from the drupal database and embeds it as hidden form field on the page, and then this is submitted over network via standard plain text http to the webmail server. So these are 2 places where the password could be sniffed and hacked over an unsecure connection. If your ISP host webmail accepts encrypted passwords, like using, md5 then this might be advisable.
This code snippet example is also an illustration of how to read use profile fields for which there is a glaring omission in the drupal documentation as to how to do this!
So, created the user profile fields.
For profile_yourdomain_email - (use only text before the @ for this field e.g. first.last@yourdomain.com just use first.last in this field)
and the profile_yourdomain_email_password.
(Some of your users may not require a webmail account, so if you leave the profile_yourdomain_email blank then the button wont appear.)
Then go to the blocks section of admin, create a new block and paste this code in.
You might need to adjust the formatting as the code renderer on this page shows some lines as multiple lines where they aren't - they are actually just one line.
I'd welcome your opinions - like if you can find a better way than this solution. I looked at the mail modules but they were still in beta and not for production or they were for IMAP only.