Closed Bug 90507 Opened 23 years ago Closed 21 years ago

when using authenticated SMTP smtp username value has "@{smtp server hostname}" appended to it

Categories

(MailNews Core :: Networking: SMTP, defect)

x86
All
defect
Not set
critical

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: Ben, Assigned: ch.ey)

References

Details

(Keywords: regression)

Attachments

(4 files)

when configuring Mozilla 0.9.2 on Windows 98 SE 
under MAIL/NEWS ACCOUNT SETTINGS; Outgoing Server (SMTP)
server name "smtp.isp.net"
selected "Use name and password"
enter username "john.doe@mydomain.org"

when sending mail mozilla sends user name to receiving SMTP MTA
as "john.doe@mydomain.org@smtp.isp.net"

Here are the settings as appear in 
C:\Windows\Application Data\Mozilla\Users\default\prefs.js

user_pref("mail.smtp.defaultserver", "smtp1");
user_pref("mail.smtp_name", "John.Doe");
user_pref("mail.smtpserver.smtp1.auth_method", 1);
user_pref("mail.smtpserver.smtp1.hostname", "smtp.isp.net");
user_pref("mail.smtpserver.smtp1.try_ssl", 0);
user_pref("mail.smtpserver.smtp1.username", "john.doe@mydomain.org");
user_pref("mail.smtpservers", "smtp1");

If I try to set the user name to just "john.doe" 
mozilla tries to send the user name "john.doe@smtp.isp.net"

The user name field should be used verbatim as entered, with nothing appended or 
removed.
I am not a C programmer, (although I have cobbled together a few C programs)

I *think* (although I could be horribly wrong) 
that the problem lies around line 359 in 
mozilla/mailnews/compose/src/nsSmtpServer.cpp

NS_IMETHODIMP
nsSmtpServer::GetServerURI(char **aResult)
{
    NS_ENSURE_ARG_POINTER(aResult);
    nsresult rv;
    nsCAutoString uri;
 
    uri += "smtp";
    uri += "://";
 
    nsXPIDLCString username;
    rv = GetUsername(getter_Copies(username));
 
    if (NS_SUCCEEDED(rv) && ((const char*)username) && username[0]) {
        nsXPIDLCString escapedUsername;
        *((char **)getter_Copies(escapedUsername)) =
            nsEscape(username, url_XAlphas);
//            nsEscape(username, url_Path);
        // not all servers have a username
        uri.Append(escapedUsername);
        uri += '@';
    }
 
    nsXPIDLCString hostname;
    rv = GetHostname(getter_Copies(hostname));
 
    if (NS_SUCCEEDED(rv) && ((const char*)hostname) && hostname[0]) {
        nsXPIDLCString escapedHostname;
        *((char **)getter_Copies(escapedHostname)) =
            nsEscape(hostname, url_Path);
        // not all servers have a hostname
        uri.Append(escapedHostname);
    }
 
    *aResult = uri.ToNewCString();
    return NS_OK;
}
Well, I downloaded the source and commented out those uri.append lines in the
comment I made previously with the source code snippet in it, then built and ran
it didn't fix the problem at all. I guess I was "horribly" wrong.

However I can now say that I tried this same bug under Linux on X86 with the
07122001 nightly CVS full source dump and it has the same SMTP username bug
there too.
I#ve noticed this too, but my outgoing mails work OK.
Running Mozzilla under Windows98 and RedHat Linux 7.1 and I have noticed this 
same error.
Marking NEW based on confirmation.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: regression
Blocks: 81387
I've also this in windows 2000 and windows 98, today build 2001102119, and this 
is (for me at least) a bit critical as the mail servers of the major internet 
operation in Portugal don't send mail correctly. It fails to send the mail, 
asking several times for the password and then closes the window without error 
message but doesnt send the mail.
When sendmail 8.11 is configured to use pam for authentication, it uses just the
password portion, and ignores the @server.domain part of the name provided.

When sendmail is configured to use SASLDB for authentication, it uses the part
of the username after the @ to provide the 'Realm' information - which often is
the machine name, but is NOT necessarily equivalent to the fully qualified
server name.

This may be why some servers accept the current behaviour - and why the user
entered name should be passed to the server without change or addition to the
suffix.
Keywords: mozilla1.0
I can no longer use Netscape's mail client to send SMTP mail via Yahoo's SMTP 
server.  Per Yahoo, this problem is caused because Yahoo now requires 
authenticated SMTP, which Netscape 6.2 is not able to handle in the way Yahoo 
requires.  I can still download mail via the POP server, but I cannot send mail 
via SMPT.  This would be my highest priority for fixing.
is this on the release notes?
OS: Windows 98 → All
A small work around I'e found -- depending on your mail server, some support
authenticating using user$hostname rather than user@hostname.  One server that I
know of that supports this is MDAEMON for Windows, not sure if qmail or sendmail
sport this nifty feature or not.
Nevermind that work around, it stopped working.
This patch seems to correct the blank server lines in Account - Advanced, and I
think bug 86370, bug 143588 and maybe a couple of others.  Tested in 1.0, 1.1b
and 1.1 release on Linux.  I blagged the code from the equivalent bit of the
IMAP service, so I hope it's sound.  The business with duplicated SMTP servers
in Outgoing - Advanced (bugs 96207, 69630?) could be related to usernames as
well, but the problem seems to be somewhere else.
On XP, if I try to setup smtp authentication for mochamail - which it requires -
it will not send out the mail. If smtp authentication is disabled, it sends
ok...which seems very odd.
*** Bug 182999 has been marked as a duplicate of this bug. ***
*** Bug 183050 has been marked as a duplicate of this bug. ***
*** Bug 168505 has been marked as a duplicate of this bug. ***
*** Bug 185941 has been marked as a duplicate of this bug. ***
I believe this is the same bug I have on Mac OSX using the current 1.3 nightly
(Gecko/20030110). I have a username dmischel@sbcglobal.net but the smtp server,
which requires authentication, is not smtp.sbcglobal.net but
smtp.sbcglobal.yahoo.com. When I try to send mail Mozilla authenticates as
either dmischel@sbcglobal.net@smtp.sbcglobal.yahoo.com or
dmischel@smtp.sbcglobal.yahoo.com.

Both are wrong. I can't get my mail on the Mac. On XP this same nightly works
fine because it does not append the smtp server name to the user name.
Depends on: 86370
Bug 187635 seems related to this one, IMHO
This bug makes it impossible to use a SBC Yahoo account to receive mail. Your
username is user@sbcglobal.net, & you must authenticate against
pop.sbcglobal.yahoo.com. Since you're actually authenticating against
user@sbcglobal.net@pop.sbcglobal.yahoo.com, it fails every time.

I have a client who cannot use Mozilla now, as she just switched to SBC Yahoo.
Blocks: 193931
Flags: blocking1.4b?
Keywords: mozilla1.0nsbeta1
*** Bug 167860 has been marked as a duplicate of this bug. ***
I've read through this bug again and again. But I'm not sure what it is about
anyway.

The reporter writes: If I try to set the user name to just "john.doe" mozilla
tries to send the user name "john.doe@smtp.isp.net"

How do you want to know Mozilla sends "john.doe@smtp.isp.net" as username to the
server? Did you saw this using a paketsniffer or something like this?

Scott, you wrote in comment #20: "Your username is user@sbcglobal.net, & you
must authenticate against pop.sbcglobal.yahoo.com. Since you're actually
authenticating against user@sbcglobal.net@pop.sbcglobal.yahoo.com, it fails
every time."
What do you mean with "authenticate against"?

It is right, that Mozilla, when asking for password, writes something like
"enter password for user@email.com@mysmtpserver.net". But this doesn't mean it
really sends this "username" to the server.

I think I know the SMTP and POP code and what it sends out. Nevertheless I just
tested it live in the debugger and it really really sends only the user names
entered in the appropriate fields.

I agree the message displayed when asking for password is bad, but I can't find
an error in the code regarding the username being sent.

If anyone of you has problems when logging into a server I think the reason is
another one. But if you're sure the wrong username is sent, please show me any
evidence for this (log from Ethereal or Mozilla log of a debug build).
Flags: blocking1.4b? → blocking1.4b-
As I wrote, asking for password for "user@email.com@mysmtpserver.net" is ugly
but no functional flaw. It' only username and password filled in the template
"Enter your password for %1$s@%2$s:"

Would you agree to change this string to something like "Enter your password for
%1$s loggin in to %2$s:"?
adt: nsbeta1-
Keywords: nsbeta1nsbeta1-
OK, this is all very confusing, but I think the problem I have is related. My
problem has only arisen since this morning when I upgraded from 1.2.1 to 1.3

4 accounts:
mail@danbrusca.com
dan@notnet.co.uk
mail@kelsomedia.co.uk
mail@patriciapotter.co.uk

Up until this morning I could send email without difficulty on all 4 accounts
through my smtpserver.com. Since upgrading, I can only send mail on
mail@danbrusca.com without difficulty.

When I try and send through dan@notnet.co.uk I am prompted to enter a password
for dan@smtpserver.com
When I try and send through mail@kelsomedia.co.uk I am prompted to enter a
password for mail@smtpserver.com
When I try and send through mail@patriciapotter.co.uk I am prompted to enter a
password for mail@smtpserver.com

Mozilla doesn't acept any password that is entered, leading to inevitible send
failure.

Now, I changed all the settings for the dan@notnet.co.uk account so that it
effectively became an exact copy of mail@danbrusca.com and then restarted
Mozilla. On trying to send mail through this 'clone' account I was *still*
prompted to enter a password for dan@smtpserver.com even though my Mozilla
settings and preferences contained no reference whatsoever to 'dan'. Again, my
password wasn't accepted.

There is clearly a bug here and a pretty serious one as I am completely unable
to send email through any of my alternate accounts (I have 7 in total).
Dan, what you're write about clearly is a bug. But I suggest it's more bug
187635 than this here.
If you agree, would you place your comment there too please?
Done.
OK, after many frustrating hours I've solved what was causing my problem. I have
no idea if this has any bearing beyond my own circumstances, so feel free to
discard this post if irrelevant.

Investigation has revealed that somewhere during the upgrade process a whole
bunch of spurious SMTP server entries were created in the 'Advanced' section of
SMTP server settings. These were being called whenever I was trying to send email. 

Point to note, Mozilla was tring to send mail through the first server specified
in the list, *not* the default.

Deleting all the entries except the default eliminated the problem.
So how do I fix this so I can send mail. It has also corrupted by Netscape 7.0
so I can't send from the account that way either.
Rowan, what's your exact problem? In which build?
i upgraded from 1.4b to 1.4 (Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; 
rv:1.4) Gecko/20030624) today and started having a problem with one of my 2 
smtp auth servers.  i have 2 accounts each with their own server, id, and smtp 
settings in the prefs.js

here's a pertient excerpt from my pref.js with names changed for privacy:

user_pref("mail.smtp.defaultserver", "smtp1");
user_pref("mail.smtpserver.smtp1.auth_method", 1);
user_pref("mail.smtpserver.smtp1.hostname", "mail.aaa.com");
user_pref("mail.smtpserver.smtp1.port", 25);
user_pref("mail.smtpserver.smtp1.try_ssl", 2);
user_pref("mail.smtpserver.smtp1.username", "user1@bbb.com");
user_pref("mail.smtpserver.smtp2.auth_method", 1);
user_pref("mail.smtpserver.smtp2.hostname", "mail.ccc.com");
user_pref("mail.smtpserver.smtp2.port", 2500);
user_pref("mail.smtpserver.smtp2.try_ssl", 2);
user_pref("mail.smtpserver.smtp2.username", "user2");

when i try to send to smtp1, the smtp server only sees authid=user1 (as per 
the logfile for the smtp server on mail.aaa.com's port 25).  mozilla should be 
sending user1@bbb.com to smtp1.  note that the password window that mozilla 
launchs does show user1@bbb.com@mail.aaa.com as it used to, but only user1 is 
being sent (not user1@bbb.com as needed).

sending to smtp2 works fine.

email to smtp1 worked fine before i upgraded from 1.4b to 1.4 today.
some additional details following up with
http://bugzilla.mozilla.org/show_bug.cgi?id=90507#c31

for comparitive diagnostics, this auth server works fine for other clients i have:
- my 1.4b winxp client worked fine before the upgrade
- my netscape 4.8 client works fine
- my linux mozilla 1.3 client works fine

i created a new profile with just the one email account to that one smtp auth
server.  results are the same.  sendmail log shows authid=user1, i.e. it does
not show user1@bbb.com as it should.

changing the username from user1@bbb.com in mozilla to user1$bbb.com fails in
the smtp auth sendmail as it does not see a valid username.  i am not well read
on tis, but i believe sendmail uses sasl to validate the user and realm and i
guess the @ is the required token delimiter for that parser.

i am considering rolling back my winxp with a system restore just prior to
upgrading from 1.4b to 1.4.  this is painful and does not address the root cause.

any help is appreciated.
additional followup to my prior postings
http://bugzilla.mozilla.org/show_bug.cgi?id=90507#c31
http://bugzilla.mozilla.org/show_bug.cgi?id=90507#c32

didn't think this would have an impact, but now that i've invested lots of time
trying to find a way to get things working again, i thought i should share this:

the first time i upgraded to 1.4 i did not first uninstall 1.4b.  the install
would not complete.  after reviewing the relnotes, i uninstalled 1.4 as
instructed, disabled my mcafee, and then reinstalled 1.4.  the install worked
and then the smtp problem started happening.

note that the profile in use was converted/inported from a netscape 4.x profile
by an earlier mozilla release.  sharing this in case there's a known problem
with something in the prefs.js, et.al.  i read thru all the prefs and everything
looked ok.

i also tried a winxp system restore back to a checkpoint before i had upgraded
to 1.4 (from 1.4b).  mozilla would not even start.

so, at this point i've set both my email accounts to use the same outgoing smtp
auth.  this works.  but i need to really set each account to use different smtp
auths.

since my netscape 4.8 works with the smtp auth that mozilla 1.4 does not work,
and mozilla 1.3 on my linux works, and 1.4b worked, i've got to believe the
problem is something with 1.4 or the install.  not sure why going back to 1.4b
would not work.  perhaps something get changed in prefs.js or are there win
dll's somewhere that are not getting deleted?

i am now at a loss as to what to try next.

h-e-l-p.
My user name uses a different domain name then my SMTP Server
Example: 
    Server Name: SMTP.EmailWebServerFarm.Com
    User Name: UserName@HostedDomainName.com

and this causes the User Name that it tries to resolve to be:
    UserName@HostedDomainName.com@SMTP.EmailWebServerFarm.Com
John, and this doesn't work?
As I wrote in comment 22 and 23 name@domain@server isn't wrong because it's just
a string for the display.

If it doesn't work though in your case, we've to find out why.
Attached patch proposed patchSplinter Review
This patch does basically the same for SMTP what was done in bug 212937 for
POP3.

The problem here is, that in case of some redirectors the hostname has to be
suppressed. Currently this is simple since the string with @hostname is
appended in the code.
But now with having a "on" or other (more) words in other languages I don't
know how to handle this in respect to localization other than with two
different strings.
Attachment #133633 - Flags: review?(bienvenu)
Comment on attachment 133633 [details] [diff] [review]
proposed patch

we don't care so much about the redirector stuff anymore, at least for
aol/netscape, for obvious reasons.
Attachment #133633 - Flags: review?(bienvenu) → review+
> we don't care so much about the redirector stuff anymore, at least for
> aol/netscape, for obvious reasons.

But not so little to remove it or ignore it in this case, yes? So we'll have to
live with this solution at least for a while.
right, we don't want to lose the functionality in case we want it in the future.
I'll apply this patch and check it in after running with it for a bit.
reassigning
Assignee: mscott → ch.ey
fix checked in.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
sorry for being naive...
how do i get this fix to test?
Get a trunk build newer than 2003-10-21 10:11 and try to send a mail via a SMTP
server without saved password.
You should see "Enter your password for username on hostname:" instead of "Enter
your password for username@hostname:".

The fix is no big thing, but the @ confused not few users.
re-opening - Christian and I have found a problem with this. Will attach a fix.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Attached patch proposed fixSplinter Review
I think we were crunching the stack with the previous patch because
formatStrings didn't have space for two strings. This patch fixes that and
makes the code a little simpler.
Attachment #134113 - Flags: superreview?(mscott)
Attachment #134113 - Flags: review?(ch.ey)
Comment on attachment 134113 [details] [diff] [review]
proposed fix

Yupp, that's almost my solution.
Attachment #134113 - Flags: review?(ch.ey) → review+
fix checked in, r/a=sspitzer over aim.
Status: REOPENED → RESOLVED
Closed: 21 years ago21 years ago
Resolution: --- → FIXED
I just tested this again on Windows (no yesterdays build) and I still get
"smtpserver on smtpserver" instead of "user on smtpserver".
The last patch was necessary but didn't fix this problem though.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Attached patch Fix string fuSplinter Review
The current patch has bad string fu. NS_ConvertASCIItoUCS2 creates a temporary
object which is destroyed at the end of the statement, potentially invalidating
the return value of .get(), so Dan Witte dwitte@stanford.edu provided this
patch as an example of how to safely convert strings. Hopefully this will fix
the remaining issue; I haven't tested it but it can't make things worse ;-)
I also suspect a temp thing can be the cause of this effect. Although I don't
see why a invalid assignment to formatStrings[1] could cause a valid output of
[1] and a wrong one (because it's the same as in [1]) in [0].

The code you attached works on Linux (as the previous patches before), but I
can't tell for Windows as I can't produce binaries for Win.
Of course we can try and see.
I'll check on Windows if you can point me to an authenticated smtp server
Try mail.gmx.net or smtp.myrealbox.com.
hmm, this works fine on windows as is, from what I can tell (maybe a debug build
issue?). The string fu fix looks correct, however. Let me try some more testing.
fix checked in - it works on my windows release build (it was crashing before
these two fixes)
Status: REOPENED → RESOLVED
Closed: 21 years ago21 years ago
Resolution: --- → FIXED
Crashing? Ups, hopefully only on some machines (it doesn't on mine). Otherwise
not few people won't be able to send mail with 1.6a.

Thank you all for saving my original patch.
it was my tbird release build, and it might not have had either patch (I always
forget you have to rebuild from mailnews in tbird).
Product: MailNews → Core
*** Bug 223464 has been marked as a duplicate of this bug. ***
*** Bug 195749 has been marked as a duplicate of this bug. ***
*** Bug 263883 has been marked as a duplicate of this bug. ***
*** Bug 144643 has been marked as a duplicate of this bug. ***
Attachment #134113 - Flags: superreview?(mscott)
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: