I'm trying to debug a configuration issue. here is the scenario. from ASP.Net I want to send a email to an external domain. example: from foo@foo.com, to bar@bar.com. My email server is Exchange.
If I do not use any credentials
I get a [tt]SmtpFailedRecipientException: Mailbox unavailable. The server response was: 5.7.1 Unable to relay for bar@bar.com[/tt]
If I provide my credentials
everything works successfully.
however I don't want to use my credentials in production, so I test with the account we will be using
and I get the [tt]SmtpFailedRecipientException: Mailbox unavailable. The server response was: 5.7.1 Unable to relay for bar@bar.com[/tt] error again.
according to MSDN Mailbox unavailable means "The destination mailbox was not found or could not be accessed". At first I thought this meant the "other user" mailbox, but "other user" has a mailbox configured. Now I'm thinking it means "bar@bar.com", but that doesn't make sense either since it was sent successfully using my credentials.
has anyone encountered this before? If so, how did you resolve this issue?
Jason Meckley
Programmer
Specialty Bakers, Inc.
faq855-7190
faq732-7259
If I do not use any credentials
Code:
var message = new MailMessage {
From = new MailAddress("foo@foo.com"),
Subject = "...",
Body = "testing relay message"
};
using(message)
{
message.To.Add("bar@bar.com");
new SmtpClient("exchange server").Send(message);
}
If I provide my credentials
Code:
var credentials = new NetworkCredential {
UserName = "user name",
Password = "secret",
Domain = "DOMAIN"
};
var message = new MailMessage {
Credentials = credentials,
From = new MailAddress("foo@foo.com"),
Subject = "...",
Body = "testing relay message"
};
using(message)
{
message.To.Add("bar@bar.com");
new SmtpClient("exchange server").Send(message);
}
however I don't want to use my credentials in production, so I test with the account we will be using
Code:
var credentials = new NetworkCredential {
UserName = "other user",
Password = "correct password",
Domain = "DOMAIN"
};
var message = new MailMessage {
Credentials = credentials,
From = new MailAddress("foo@foo.com"),
Subject = "...",
Body = "testing relay message"
};
using(message)
{
message.To.Add("bar@bar.com");
new SmtpClient("exchange server").Send(message);
}
according to MSDN Mailbox unavailable means "The destination mailbox was not found or could not be accessed". At first I thought this meant the "other user" mailbox, but "other user" has a mailbox configured. Now I'm thinking it means "bar@bar.com", but that doesn't make sense either since it was sent successfully using my credentials.
has anyone encountered this before? If so, how did you resolve this issue?
Jason Meckley
Programmer
Specialty Bakers, Inc.
faq855-7190
faq732-7259