Roundcube Community Forum

 

login and redirect to compose page

Started by aweirig, October 21, 2008, 09:39:14 AM

Previous topic - Next topic

aweirig

Hello,

I'm trying to achieve to following transition into RC.

Users login (userid + password) to our website.
Somewhere on our site they find links to send emails to given adresses.

When the user clicks on such a link, I would like to log the user into RC and direct him to the compose page showing a prepared email template (prefilled to, cc, bcc, subject, body etc),

I can achieve both goals individually, i.e. I know how to log the user into RC using a standard form or even by passing the userid + password in the URL and slightly changing index.php to accept parameters from URL.
I can also build a URL with _task=mail&_action=compose&...... to show the compose page ONCE the user is logged into RC.

But currently I can't find a way to achieve both actions in "a single step".

Any help is greatly appreciated.

Alex

rosali

#1
I do not see the sense why you want to do this with RoundCube. There are lots of form mailer scripts which are much more suiteable for your purpose (f.e.: Class: sendmail (sendmail) - PHP Classes)
Regards,
Rosali

aweirig

Hi,

thanks for answering my post.

I agree with you and I know about those classes but in this very specific situation people must send those emails from their personal mailbox (i.e. the send email must show up in the Sent Items), the identity of the sender must be "guaranteed" through the mail client.

We need this in an Intranet solution and have an obligation to work like this.

I have done using Squirrelmail but I'm not too eager on using SM, I prefer RC but if RC can't be changed to support our needs, I'll have to go back to SM.

Alex

CarlB

I doubt Alex will see this seven months later but...

It can be done.

I am working on the same kind of thing and found this:

Roundcube login via PHP script : Yet another web log

you can change the redirect() redirect code to something like:

$sendto = $_GET['sendto'];

$rcl->redirect("?_task=mail&_action=compose&_to=$sendto");


I can get this script to meet my needs, but only when using clear text password! I can only pull my mail sites user name and a MD5 of the password from a cookie...

rosali

By default RC does not store the password, not even an md5 hash of the password. The encrypted password is only available during a valid RC session.

Perhaps I will write a plugin for RC 0.3 to store an md5 hash of the password in the user_prefs database field.

Meanwhile you have to use the weak plain text method.
Regards,
Rosali

rosali

Here is a plugin to get user's password.

You get the md5 hash of the password by ...

$hash 
md5(savepassword::getpw("[email protected]"));


Plugin code (folder name "savepassword")

<?php

/**
 * Save password plugin
 *
 *
 * @version 1.0 - 21.06.2009
 * @author Roland 'rosali' Liebl
 * @website http://dl.roland-liebl.de/RoundCube/plugins/savepassword
 * @licence GNU GPL
 *
 *
 **/
 
/** USAGE
 *
 * #1- Alter RoundCube Database table `users`:
 *
 *     ALTER TABLE `users` ADD `password` TEXT NULL AFTER `last_login` ;
 *
 * #2- Register plugin ("./config/main.inc.php ::: $rcmail_config['plugins']").
 * #3- Get the password when user is not logged in:
 *     
 *     $password = savepassword::getpw("[email protected]");
 *
 **/
 
class savepassword extends rcube_plugin
{

    function 
init()
    {
        
$this->add_hook('login_after', array($this'savepw'));
    }

    function 
savepw($args)
    {
    
        
$rcmail rcmail::get_instance();

        if(
$_SESSION['user_id']){ // user has been authenticated successfully
          
$query "UPDATE `".get_table_name('users')."`
                SET  password=? 
                WHERE user_id=?;"
;
                  
          
$ret $rcmail->db->query($query,$_SESSION['password'],$_SESSION['user_id']);
        
        }

        return 
$args;
    }
    
    function 
getpw($username){
    
        
$rcmail rcmail::get_instance();    
    
        
$rcmail->db->query("
                SELECT * FROM "
.get_table_name('users')."
                WHERE  username=?"
,
                
$username);
            
        
$user $rcmail->db->fetch_assoc();
        
        if(isset(
$user['password'])){
          return 
$rcmail->decrypt($user['password']);
        }
        else{
          return 
false;
        }
    }

}

?>
Regards,
Rosali