Invalid Addresses sendmail exception

Hi! I'm having a new problem w/ sendmail, new in the sense that I've used sendmail many times before but have never experienced this problem 'til now. Back story: I recently learned that, without announcement, the address I'd been using for an SMTP server was removed about six months ago; I was given a "new," numerical (the old address had been a text alias) IP, which works fine in my Python apps without my having had to do anything other than simply swap out the old for the new. However, using it similarly with sendmail I now get:
Java exception occurred:
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for <un>@<my.domain>
with the "nested exception is:..." part repeated several times for each of the addresses I have in my cell array.
After a little searching online it sounds like my problem is most likely "Your smtp server forbids relaying, which is very common. Often a smtp server is configured to send only mails within the same domain without authentication." However, the sender address is also @<my.domain>--that's the same domain, yes? Is it possible that the way the javax.mail object is presenting the sender and recipient addresses to the smtp server is masking the fact that they're from the same domain? If so, workaround? Any other ideas? Thanks!

 Accepted Answer

Go back to the basics. Telnet to the sendmail port on the new mail server and run a session by hand. Give a HELO line, then a MAIIL FROM command line, and then a RCPT TO command line, and see if you get rejected.
The relaying bit is about the domain that the server considers itself to be: it will not allow mail to be sent to what it thinks is a different domain than it is. For example if it knows itself as (say) wa.state.gov then it would think wa.gov as a destination was outside itself.

15 Comments

How do I find out the "sendmail port"? Thanks!
OK, I figured out that the sendmail port is 25, telnet-ed in. The login acknowledgement was "220 <stuff>.<not.my.domain> Microsoft ESMTP MAIL Service, Version: 7.5.7600.16601 ready at Fri, 18 May 2012 17:07:29 -0700" and the reply to helo was "250 <stuff>.<not.my.domain> Hello [<numerical IP>]" I logged into. Based on what you said, I presume the problem is that the server domain is <not.my.domain> instead of <my.domain>--is the soln. as simple as providing the emails as <un>@<not.my.domain>? I'll find out...
Well, changing recipient to @<not.my.domain> removed the raising of the exception, but I'm not actually getting any of the mail I'm sending myself. The help for the MAIL FROM and RCPT TO commands was non-existent, so I didn't successfully execute those--in case they provided crucial info--but I just found info on them online, so I'm going to "go back in" and see what I can learn from them.
OK, HELO <my.domain> returns:
"250 <SMTP.text.IP.domain> Hello [<different numerical IP>]" (presumably <my.domain> as a numeric IP)
MAIL FROM: <myemail@my.domain> returns:
"250 2.1.0 <myemail@my.domain>....Sender OK"
RCPT TO: <myemail@my.domain> returns:
"550 5.7.1 Unable to relay for <myemail@my.domain>"
RCPT TO: <myemail@SMTP.text.IP.domain> returns:
"250 2.1.5 <myemail@SMTP.text.IP.domain>" (without the trailing "... Recipient ok" I was expecting from the Web page where I found the syntax of these commands)
Next I entered DATA, then a Subject: Testing, followed by two Enters, then a line of text, then an Enter, a period, and an Enter and I got:
"250 2.6.0 <<gibberish>@<SMTP.SMTP.text.IP.domain>> Queued mail for delivery" (whereas the Web page I found led me to hope for "250 2.0.0 ???????? Message accepted for delivery")
And sure enough, I have yet to receive the email. OK, so clearly something having to do with these damn domain names is amiss, but the fact that I can queue a message but not actually receive it...AAARRRGGGHHH! :-( Time to call it a week!
You are doing well in this investigation. A lot of people would never have located the SMTP documents and figured out how to apply them.
The problem with RCPT TO: <myemail@SMTP.text.IP.domain> is that since that is the name of the server itself, it is going to try to deliver the message right on the server, rather than trying to send it on to you.
I would probably try to do an nslookup query for the MX record of the domain you are trying to deliver to. For example at a Unix prompt,
$ nslookup -q=mx hushmail.com.
[...]
hushmail.com mail exchanger = 10 mx1.hushmail.com.
hushmail.com mail exchanger = 10 mx2.hushmail.com.
hushmail.com mail exchanger = 10 mx3.hushmail.com.
$ nslookup -q=a mx1.hushmail.com.
[...]
Name: mx1.hushmail.com
Address: 65.39.178.142
Thanks, Walter: it's not hard to be patient and persistent when you're on the clock, so to speak. ;-)
OK, here's what I get:
Z:\>nslookup -q=mx ecy.wa.gov
Server: <SMTP.text.IP.domain>
Address: 165.XXX.XXX.XXX
Non-authoritative answer:
ecy.wa.gov MX preference = 10, mail exchanger = wamsg.wa.gov
wamsg.wa.gov internet address = 198.XXX.XXX.XXX
wamsg.wa.gov internet address = 198.XXX.XXX.XXX
So I guess I'll just repeat the exercise above w/ the three XXX options and see which gets to me. ;-)
Thanks again!
DG
Well, I tried all three, as well as their text alii, and received:
550 5.7.1 Unable to relay for <myemail@nslookup.result>
in all cases. Further suggestions? Thanks!
Well it is possible that they have deliberately configured to require authentication to send mail anywhere useful.
You seem to be getting a different dialog than I am getting:
$ telnet wamsg.wa.gov smtp
Trying 198.238.87.132...
Connected to wamsg.wa.gov.
Escape character is '^]'.
220 WAMSG.WA.GOV ESMTP
HELO cetcf.xxxxx.xxxx
250 WAMSG.WA.GOV
MAIL FROM:<roberson@xxxxxl.com>
250 sender <roberson@xxxxx.com> ok
RCPT TO:<xxxxxx@ecy.wa.gov>
250 recipient <xxxxxx@ecy.wa.gov> ok
quit
221 WAMSG.WA.GOV
Connection closed by foreign host.
[quote]Well it is possible that they have deliberately configured to require authentication to send mail anywhere useful.[/quote]
Anything's possible: they took something my soiftware depended on out of commision and didn't notify me for 6 mo. (and then only 'cause I was using the address again in a new program and when I tested it it didn't work)!
[quote]You seem to be getting a different dialog than I am getting:[/quote]
You're tellin' me: I can't even establish a connection on the IP you used! (FYI: I'm using putty, 'cause they just upgraded me to Windows 7 and if it comes w/ a working DOS telnet client, I can't find it.)
Is there a way, i.e., a command or script, to get a list from the server of the domains it will relay to without authentication? Also, here's the reference I found for the telnet mail ops:
http://yuki-onna.co.uk/email/smtp.html
And here's what it has to say about the first three commands:
"...delcare where you are sending the email from:
HELO local.domain.name - dont worry too much about your local domain name although you really should use your exact fully qualified domain name as seen by the outside world the mail server" (My email address domain is ecy.wa.gov, so that's what I've used here.)
"Now give your email address:
MAIL FROM: mail@domain.ext" (this seems unambiguous--I used dgol461@ecy.wa.gov)
"Now give the recipients address:
RCPT TO: mail@otherdomain.ext" (this is where, if I provide my own email address verbatim, it says unable to relay; if I use my email prefix @ server I've logged into, it "queues" the email but I never get it; if I use my email prefix @ any of the nslookup results, it also says unable to relay.)
Can you confirm that my arguments are what is intended by these the instructions, i.e., am I feeding the machine garbage (because we all know what comes out in that case)?
Thanks again!
There is no way to find out through a command or script which domains a server will relay to without authentication.
Note that you used
RCPT TO: mail@otherdomain.ext
but I used
RCPT TO:<mail@otherdomain.ext>
The SMTP standards are not clear as to whether the <> are needed or not, but in practice the <> are always used in decent mail programs. I have seen some mail programs use MAIL FROM: without using the <> but I do not count on it.
There is another address for wamsg.wa.gov which is the immediately adjacent IP address. If the addresses you are getting are different then they are using different servers for inside and outside for whatever reason. I do see from your nslookup result that the name is at least the same, but one of the parts you obscured was whether the server you reach introduces itself under that name.
[quote]Note that you used RCPT TO: mail@otherdomain.ext but I used
RCPT TO:<mail@otherdomain.ext>[/quote]
Yeah, I "just" learned about that from here: http://www.simplescripts.de/smtp-check-port-25-telnet-command.htm
Unfortunately, it didn't solve the problem: even w/ the <>, I'm still being told "Unable to relay"
OK, here's a complete, unredacted, session transcript (I figured out how to "enable" telnet in Windows 7):
Z:\>nslookup -q=mx ecy.wa.gov
Server: ecygclcy01.ecy.wa.lcl
Address: 165.151.24.29
Non-authoritative answer:
ecy.wa.gov MX preference = 10, mail exchanger = wamsg.wa.gov
wamsg.wa.gov internet address = 198.238.87.133
wamsg.wa.gov internet address = 198.238.87.132
Z:\>telnet 198.238.87.132 25
Connecting To 198.238.87.132...Could not open connection to the host, on port 25
: Connect failed
Z:\>telnet 165.151.24.29 25
Connecting To 165.151.24.29...Could not open connection to the host, on port 25:
Connect failed
Z:\>REM This is the address I was told to use
Z:\>telnet 165.151.24.51 25
220 ecyaplcyadsmtp1.ecy.wa.lcl Microsoft ESMTP MAIL Service, Version: 7.5.7600.1
6601 ready at Mon, 21 May 2012 16:54:12 -0700
helo ecy.wa.gov
250 ecyaplcyadsmtp1.ecy.wa.lcl Hello [165.151.52.125]
mail from: <dgol461@ecy.wa.gov>
250 2.1.0 dgol461@ecy.wa.gov....Sender OK
rcpt to: <dgol461@ecy.wa.gov>
550 5.7.1 Unable to relay for dgol461@ecy.wa.gov
HTHYHM,
DG
I can reach that server, but it does not want to deliver mail to you.
My opinion is that the server you have been told to use is not configured properly for you to send mail. I would complain to the technical support team. (Okay, I wouldn't *complain*, because systems administrators are subtle and quick to anger.)
Perhaps that's why a whole day has passed and they have yet to respond to my ticket filed last Friday. ;-) I've got one more lead to run down before I give up (at least for today).
Yup, that was it, thanks for your help!
What was the solution eventually?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!