# Courier-imap - can't login

## Gav

I have been trying to setup my new gentoo based personal server and have come acros a problem I can't find my way round!

I have getmail installed bringing Email in into a couple of maildir mail boxes ("root" and my user "gav"). I think there may be some work to do with allowing my user "gav" to create directories and files in /home/gav, otherwise it seems to work - or at least enough to move on.

Now I have installed courier-imap as in the desktop guide. Previous to that I installed the whole courier server, then realised I only needed the IMAP part. I "emerged unmerge" and then got rid of the files from /etc/init.d/ relating to courier. The subsequent emerge of courier-imap seemed to go okay. I've got squirrelmail on there as well as Apache with PHP. Neither squirrelmail nor telnetting into courier (socket 143) will let me get anywhere. I read another thread about creating the .maildir for each user, but I have them already.

I *think* my problem is with the authenication side of things. Although I think I have MySQL already setup (or if not will do soon for my web dev stuff), I don't want to use it for IMAP. I've read some stuff about PAM - more from the courier-mta website. I don't get what I have to configure to authenticate with PAM. Did I emerged wrong "emerge courier-imap", not having PAM in my whatever it was??

Please can someone help me to get IMAP allowing me to log on. Although I know UNIX/Linux a bit, I'm still a newbie at most tasks, so typing the whole commands is greatly appreciated!

----------

## BackSeat

 *Gav wrote:*   

> I think there may be some work to do with allowing my user "gav" to create directories and files in /home/gav, otherwise it seems to work - or at least enough to move on.

 Try:

```
# chown gav:users /home/gav
```

 *Gav wrote:*   

> Neither squirrelmail nor telnetting into courier (socket 143) will let me get anywhere.

 What do you mean by 'they won't let you get anywhere'? Do you get a prompt from courier-imap? If not, have you started courier (/etc/init.d/courier-imapd start)? Or do you get a prompt but you can't login? If the latter, what are you typing to log in, and what response do you get?

BS

----------

## Gav

Thanks BackSeat, I searched and found the chown command, so that's fixed.

I can telnet and it brings up the initial text indicating courier-imap is alive. I then type:

```

1 LOGIN gav xxxxxxxx

```

or

```

1 LOGIN root xxxxxxxx

```

(xxxxxxxx instead of my passwords) but it says something about user not found. I'm now at work and the gentoo box is at home so I can't check exactly what.

Basically I'm after the commands to get users added (if there are any other than setting up .maildir's) to courier-imap, and how to authenticate these users.

----------

## esherrouse

I might be jumping ahead here, but I am going back over my set up of Courier/Mutt/SquirrelMail etc  and right now I am testing to make sure IMAP is working.. and I am getting the following error when I test from MUTT by the example on the Docs page...

# mutt -f imap://localhost

Could not negotiate TLS connection

Any thoughts???

Thanks,

Esh

----------

## Gav

My error when I type "1 LOGIN gav password" is:

```

1 NO login failed

```

I have read some more about PAM, but don't get what my pam.d files shoudl look like - could that be the problem?

----------

## Gav

Please can someone with a working courier-imap install tell me what they did differently to the Gentoo Desktop guide. I haven't added any USE parameters for PAM anywhere and am still stuck. I seem to be going round in circles here!  :Crying or Very sad: 

----------

## esherrouse

Gaz.. I finally got mine working, but not sure if I am the best to talk to on this.

What are you settings currently? and what are you using?

I have Courier-IMAP with Postfix and using SquirrelMail for Web and Mutt for text...

talk later

esh

----------

## Gav

 *esherrouse wrote:*   

> 
> 
> What are you settings currently? and what are you using?
> 
> I have Courier-IMAP with Postfix and using SquirrelMail for Web and Mutt for text...
> ...

 

I have resinstalled this evening to the default - the only the modifications as given in the Desktop Guide. I had previously tried various settings, but to no avail.

The setup is getmail checking my pop3 boxes, delivering to maildir's -> Courier IMAP -> SquirrelMail for a web interface. I know Courier is the problem!

----------

## esherrouse

Make sure your ./maildir is created by the user that is using them and not root or change the ownership to the user and the users group...

Example:

Directory /home/BOB should be BOB:root and then

the ./maildir file inside of BOB should be BOB:users

Hmmm.

Also for security reasons, if this is a connected box I would edit your 

/etc/passwd file to not allow shell login to any users that might be out there....  if you ahve them..

Also, can you send from your Gentoo and only receive from a another mailserver that you are popping over?

If so, this might be an issue in your Postfix config with your $mydomain being commented out.

Let me know if any of this helps... or if you have already heard it all before.

Thanks

esh

PS sorry to call you Gaz, I know someone else by that name..

----------

## esherrouse

You did set up /etc/courier-imap/authdaemonrc  so that 

authpam is set, didn;t you?

also I set (in the same file) the version to version="authdaemond.plain"

after someone else suggested that...

Otherwise, I can not think of anything else I did with Courier-imap.

esh

----------

## Gav

 *esherrouse wrote:*   

> Also, can you send from your Gentoo and only receive from a another mailserver that you are popping over?
> 
> Let me know if any of this helps... or if you have already heard it all before.
> 
> PS sorry to call you Gaz, I know someone else by that name..

 

My gentoo box has been able to send Email out and me get it from a Pop3 box. I meant to say last post that I don't host the Pop3 mailboxes - they're on my ISP and my web hosting...

I'd heard most already. I basically am trying to work out how to setup to authenticate. I don't mind PAM, pwd or MySQL - I just want to get it working!

No worries about calling me Gaz - similar names etc... Cheers for helping!

----------

## Gav

 *esherrouse wrote:*   

> You did set up /etc/courier-imap/authdaemonrc  so that 
> 
> authpam is set, didn;t you?
> 
> also I set (in the same file) the version to version="authdaemond.plain"
> ...

 

I've just done those. I had the authpam set already. It doesn't make any difference. I restarted authdaemond before trying

```

telnet localhost 143

1 LOGIN gav password

```

and it still says

```
1 NO Login failed.
```

----------

## esherrouse

Ok... so you are working in terms of Sending and receiving (though you are receiving via FetchMail or something of the sort) and that is what you want.  Your issue is working on how to set up a secure authentication method, correct?

I was thinking you were having trouble receiving directly rather than from a remote server that you were Fetching it from...  

Please let me know if this is correct.. Sorry if I missed it the first time around.

Thanks,

esh

----------

## Gav

Yes, I'm having problems with the authentication.

----------

## esherrouse

Ok.. I just ran though  trying to replicate your error.

Is there anyway you can add another user and test with that new one?

I am sure you have already done this.

I just tested with multiple accounts and they all seem to work fine even the most restricted ones. 

Still trying to plug away and see what I can find.

If you know the user Torg, he was able to help me, and if he is around he might be able to help you a bit more than I can...

still trying

esh

----------

## esherrouse

I just created an account with out any .maildir or home/useraccount and I get a different error all together.  The only time I see this error is with invalid passwd or user info.

----------

## Gav

 *esherrouse wrote:*   

> Ok.. I just ran though  trying to replicate your error.
> 
> Is there anyway you can add another user and test with that new one?
> 
> I am sure you have already done this.
> ...

 

I added user testmail. Created the maildir's and it didn't work... I'm using the Telnet localhost 143 to test...

----------

## Gav

 *esherrouse wrote:*   

> I just created an account with out any .maildir or home/useraccount and I get a different error all together.  The only time I see this error is with invalid passwd or user info.

 

So maybe I have to sync the user data to PAM??? How???

I added another user and didn't set up any home or .maildir. I got the same error, plus some more!

```
1 NO Login failed.

* NO Error in IMAP command recieved by server.
```

----------

## esherrouse

Sorry, but I am not sure what the problem is.

It sounds like we have the same set up, but I am not seeing that error.

Anyone else out there???

?

esh

----------

## Gav

I have played around a bit and now have the courier-pop3d working.  :Very Happy: 

However the IMAP wont let me in, and IMAP is the reason I'm doing this, so I have to sort it out. Can anyone post up the config they use so I can make sure I haven't got something wrong... It seems to be in the authorisation... When (if) I get it working I may try to write a webpage to explain the gentoo configuration pitfalls of this setup...

----------

## fyerk

Is your /etc/pam.d/imap file correct?

```

auth       required     pam_nologin.so

auth       required     pam_stack.so service=system-auth

account    required     pam_stack.so service=system-auth

session    required     pam_stack.so service=system-auth

```

----------

## Gav

 *edge wrote:*   

> Is your /etc/pam.d/imap file correct?
> 
> ```
> 
> auth       required     pam_nologin.so
> ...

 

It wasn't quite. Also I had missed some characters that got in the top of the file by mistake (annoying fact that switching my KVM onto my Linux machine puts the shortcut number in the currently active window).

Basically, it now seems to work fine.  :Very Happy:   Just need to sort out SquirrelMail's errors, but Outlook Express seems happy with it! Yipee!   :Very Happy:   Thankyou to everyone who helped!  :Very Happy: 

[edit] Now I have squirrelmail working too!   :Very Happy: 

----------

## TheCoop

I have the same problem, except none of the suggestions in here worked and 

```
telnet localhost 143 

1 LOGIN paul ********** 
```

only drops the connection (Connection closed by server). I need to get this working...

----------

## alfalfa

I'm having problems receiving mail since doing an 'emerge -u --deep world'  I use courier-imap (the ssl version).  I've seen some other threads on this, but haven't seen a solution yet.  Anyone have any ideas?

----------

## TheCoop

does no one know the answer? someone must have got courier-imap working. can they at least post their config, or anything else useful?

----------

## TheCoop

SORTED!!!!!!!!!!!! (at least for me)

the problem was with the firewall iptables settings, it wasnt inputting the imap connection, only forwarding it to the internet (where an imap server doesnt exist ofc)

therefore:

```
iptables -A INPUT -i eth1 -p tcp --dport 143 -j ACCEPT

iptables -A INPUT -i eth1 -p udp --dport 143 -j ACCEPT
```

(change eth1 to your internal interface)

passed the imap connection to the server rather than through to the internet. Ill need to test it fully thou, to make sure it wasnt just a fluke...

 :Very Happy:   :Very Happy:   :Very Happy:   :Very Happy:   :Very Happy:   :Very Happy: 

----------

## TheCoop

or it was that the courier-authdaemond startup script wasnt initialised at bootup...

try both of those (obv not the 1st one if you havent got an iptables setup)

----------

## -=Blade=-

What I have also found in my searches is adding PAM into the make.conf.

USE="pam" # in /etc/make.conf 

and re-emerge courier-imap!

----------

## Dr_Stein

Well, I hope so, anyway.  :Smile: 

If you followed the Gentoo virtual mail how-to like I did, one thing that I overlooked was actually logging in properly. 

I was logging in with the username "test" that I had created for my fake virtual domain "domain2.com." 

It didn't work until I logged in with the username as "test@domain2.com" instead. 

It's worth a shot. I bashed my head on the wall for hours before thinking of that.  :Smile: 

----------

## Muggen

I noticed a difference when usin telnet with putty & just telnet in the command prompt(windows).

---

putty gave me this:

1 login xxx yyy

NO Error in IMAP command received by server.

---

and telnet:

1 login xxx yyy

1 OK LOGIN Ok.

----

 :Confused: 

----------

## dumdey

Hi *,

my problem was => the authdaemond wasn't started!

See (https://forums.gentoo.org/viewtopic.php?t=37808)

The start of this daemon fixes my problem   :Very Happy: 

Cheers!

----------

## bloatedfish

I had exactly the same problem.  I could not login to the IMAP server.  I found the problem was that I hadn't started/restarted the authdaemond.  Run /etc/init.d/authdaemond stop then start, or restart.  

I hope this helps someone.

----------

## jtp755

TheCoop i am also having your problem.

----------

## Oopsz

I *always* get login failed when trying to use pop3/imap (regular or ssl).  I don't get it...  virtual and real accounts seem to be working, and they exist (so its seemingly authenticating against the mysql database) except for that it always says wrong password!

----------

## Oopsz

I'm remerging postfix, cyrus, pam-mysql and courier.. hopefully this will fix things.. this is driving me nuts   :Confused: 

----------

## jtp755

most of yall are doing better than i am.....i cant even got it to work right using telnet. i can connext using telnet localhost 143 but then it eventually kicks me back to prompt. any one have neideas?

----------

## danix

I am having the same issue.  I kept getting "too many clients cached" and so did a restart via /etc/init.d scripts, but then got the bad user error.

By restarting authdaemond I was able to log in with one account, but the other still fails.

Now searching for another imap server, this one blows goats.

----------

## nickrout

I don't know whether this helps anyone, but I just fixed a login problem by updating /etc/pam.d/imap.

this file needed the old etc-update treatment, my fault for leaving 300 odd files needing updating I guess.

----------

