Operating System - OpenVMS
1823422 Members
2497 Online
109655 Solutions
New Discussion юеВ

Re: VMS mail error %MAIL-E-NOSUCHUSR, no such user

 
Jeff Bath
Advisor

VMS mail error %MAIL-E-NOSUCHUSR, no such user

Is they a way to allow mail to continue if a specified username is no longer valid?
This is done via a batch process and the warning mail messages sometimes fail if one of the users is no longer valid.
I know the obvious way is to execute the mail command for each individual user but thats not very elegant.
14 REPLIES 14
William Webb_2
Frequent Advisor

Re: VMS mail error %MAIL-E-NOSUCHUSR, no such user

It all depends on how you're doing what you're doing.

Are you using distribution lists (.DIS) or processing a list of accounts?

Is all this happening on one local node, or are user accounts on multiple nodes involved?

Unfortunately, f$user doesn't allow you to check for the existence (or not) of a valid VMS account.

You've also not taken into account(!) the fact that a perfectly valid account might have the DISMAIL or DISNEWMAIL flags enabled.

WWWebb
Dale A. Marcy
Trusted Contributor

Re: VMS mail error %MAIL-E-NOSUCHUSR, no such user

Unfortunately, I do not know of any way to do exactly what you want to do, but something that might help a little would be to do the following:

$ Set NoOn
$ Mail/Subject="Text" Filename.Ext @Dist.Lis
$ If $Status .Eq. %X107E802A
$ Then
$ Mail/Subject="ErrorText" Filename.Ext @Known_Good_Dist.Lis
$ Set On

Keep the Known_Good_Dist.Lis to a minimum of users that are certain to be valid. This will let you know quickly when a distribution list has a problem.
Dale A. Marcy
Trusted Contributor

Re: VMS mail error %MAIL-E-NOSUCHUSR, no such user

Forgot my $ EndIf before the $ Set On. It also removed all of my indentations, so it is harder to read than what I had input.
Jeff Bath
Advisor

Re: VMS mail error %MAIL-E-NOSUCHUSR, no such user

Dale,
I have been doing something very similiar to what you suggested. I was hoping there was a better way. One alternative that I am leaning towards is just use SMTP mail only.


William,
All of the users are local. I am using a list of names like "USER1,USER2,USER3".
I guess a slick way to do it would be to use f$element in a loop and send the mail once for each user. If it fails for a specific user I could just log it and continue to the next user.

Jeff Bath
Advisor

Re: VMS mail error %MAIL-E-NOSUCHUSR, no such user

Maybe something like
$ set noverify
$ ws = "WRITE SYS$OUTPUT"
$ status_mail = "USER1,USER2,smtp%""test@test.COM"""
$ x = 0
$ set noon
$ mail_loop:
$ xuser = f$element(x,",",status_mail)
$ if xuser .nes. ","
$ then
$ x = x + 1
$ if xuser .eqs. "" then goto mail_loop !!! Just in case we find a blank element. !!!
$ ws "-I- Sending Mail to "+xuser
$ mail/noself nl: 'xuser'/subject="This is a Test"
$ if .not. $status then ws "-E- Error occured sending mail to ""''xuser'"". (''$status')"
$ goto mail_loop
$ endif
$ set on
$!
$ EXIT
John Gillings
Honored Contributor

Re: VMS mail error %MAIL-E-NOSUCHUSR, no such user

Jeff,

Get a copy of NMAIL from the freeware CD. It's a mail transport which doesn't require the usual handshake from the target node. NMAIL will retry up to some threshold (useful if the target node is down) before deciding that a message is undeliverable.

MAIL/SUBJ="subject" file nm%user1,nm%user2

If the target user doesn't exist, the send won't fail, but the NMAIL daemon will mail you back an error report.
A crucible of informative mistakes
John Gillings
Honored Contributor

Re: VMS mail error %MAIL-E-NOSUCHUSR, no such user

Oh, and for a distribution list, you can either prefix each name in the .DIS file with nm%, or in MAIL:

MAIL> SET TRANSPORT NM%

This will set it as the default transport (I don't think that ever got documented...). So, any mail address without an explicit transport will use NMAIL.
A crucible of informative mistakes
Hein van den Heuvel
Honored Contributor

Re: VMS mail error %MAIL-E-NOSUCHUSR, no such user


Here is an other thought...

You can always have a mail forward, even if the user is no longer valid.

So you could create a single dummy user name, disabled, to 'collect' stray messages for later analysis and fixes.

$MCR AUTHORIZE ADD JUNKMAIL /DEV...
$MAIL
MAIL> SET FORW JUNKMAIL/USER=SOME_USER
MAIL> SET FORW JUNKMAIL/USER=OTHER_USER

hein.
Bill Hall
Honored Contributor

Re: VMS mail error %MAIL-E-NOSUCHUSR, no such user

Hein,

Relatively current VMS mail versions don't require a VMS account (I don't recall how far back it goes V7, V6???). You can create mail forwarding entries without a corresponding VMS account.

Bill
Bill Hall
Jeff Bath
Advisor

Re: VMS mail error %MAIL-E-NOSUCHUSR, no such user

This seems like the simplest way. I came up with this with the help of a colleague.

$ pipe write sys$output "YES" | mail/sub=testing nl: user1,user2,user3




John Gillings
Honored Contributor

Re: VMS mail error %MAIL-E-NOSUCHUSR, no such user

Jeff,

>$ pipe write sys$output "YES" | mail/sub=testing nl: user1,user2,user3

This is a very long winded way of executing the MAIL command in a subprocess and ignore the return status. You actually create 2 subprocesses to execute the command. A much easier way to do that is:

$ SPAWN/NOWAIT MAIL/SUBJ="test" NL: user1,user2,user3

Even better is to use SET NOON, then you don't need to incur the cost of process creation:

$ SET NOON
$ MAIL/SUBJ="test" NL: user1,user2,user3
$ SET ON

However, with both of these mechanism, if any of those users triggers a MAIL-E-NOSUCHUSER, then NONE of them will receive mail. That's just the way MAIL works with the default transport.

If you want to make sure those users that exist get the mail, and those that don't are ignored, you can either issue one MAIL command per user, or use NMAIL as suggested earlier. NMAIL is a much better solution. It does exactly what you want. Just because it's freeware, doesn't mean it's no good. It was standard on every VMS system in Digital, and should have been incorporated into the product.
A crucible of informative mistakes
Hein van den Heuvel
Honored Contributor

Re: VMS mail error %MAIL-E-NOSUCHUSR, no such user

There is one more extremely efficient, but also extremely ugly solution.
Mail treats target usernames as logical names allowing you to define 'operator_of_the_day' to a real mail name outside the forwarding system. Exploiting that, you can define a (system wide) logical name(s) for invalid usernames translating to " ". This will make vaxmail effectively ignore those usernames and create unpredictable havoc to your system when that name is used in an other context.


Jeff>> $ pipe write sys$output "YES" | mail/sub=testing nl: user1,user2,user3

If you had a file in a known location on your system starting with a "y" or "Y", then it would be much more efficient to use:

$DEFINE/USER SYS$INPUT some_file_with_yes
$MAIL/sub=testing nl: user1,user2,user3

Bill>> Relatively current VMS mail versions don't require a VMS account

Hi Bill, yes that is what I was trying to exploit: create as many mail forwards as you need for usernames that no longer exist but used to be valid. But I would think you would then want a dedicated username to receive those mail, that's why my example included a UAF ADD. Not for the target, but for a helpr account. Of course you could also send them to an existing 'system' or an application manager account.

fwiw,
Hein.
Jeff Bath
Advisor

Re: VMS mail error %MAIL-E-NOSUCHUSR, no such user

I don't think I need to worry about efficiency in this case. This mail will only be sent in the event of an exception. Which to date has only happened maybe 4 times in then last 5 years. Also we are running this on GS1280s so I wonder if we would even notice the effects of this process.
Steve Reece_3
Trusted Contributor

Re: VMS mail error %MAIL-E-NOSUCHUSR, no such user

Just because you're only using it once in a while and on a GS1280 doesn't mean that someone, somewhere, won't see it as a really neat trick and end up using it everywhere!

FWIW, I was thinking along the same lines as Hein in creating an account to act as a bit bucket for undelivered mail and forward old users' mail to there.

You could, I suppose, use system services to check whether a user exists before trying to mail them... You could probably even check the account exists using the example I got from somewhere of what the new mail count was for the user - no directory, no username one would hope they wouldn't have a new mail count!