what is means of this problem when sending email through web-application - c#

i have this error when i sending email through our web application
" Mailbox unavailable. The server response was: Requested action not taken: mailbox unavailable or not local"
this is detail of error
System.Net.Mail.SmtpFailedRecipientException was caught
Message=Mailbox unavailable. The server response was: Requested action not taken: mailbox unavailable or not local
Source=System
FailedRecipient=<email#email.com>
StackTrace:
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at email.Globals.SendMail(String EmailID, String subject, String message, String senderMail) in C:location
InnerException:

I would assume that your sender credentials are not in order - if the recipient's mailbox is unavailable, you will get an E-Mail saying so but the actual sending process should work out (if it's not a local recipient).
If I had to guess, I'd say you are trying to send an E-Mail with a sender address belonging to a domain that is not managed by the SMTP server you are using to send the E-Mail (e.g. a GMail address).

It means that the mailbox belonging to "email#email.com" is either not available (it is over its quota or something similar) OR the server is not allowing you to relay emails (which it would have to do if "email#email.com" is not a local domain). It is common for mail servers to behave this way, because it is not desirable for a mail server to act as an open relay.
My best guess is that you problem has to do with the latter. If you have control over the server, you could allow relaying from the server that's hosting your web application.

Related

SMTP: cannot send email from windows server 2012

I have strictly followed this tutorial in order to configure SMTP server on Windows Server 2012 R2 by usng IIS 6. In fact, if I create a correct formatted file email.txt inside
C:\inetpub\mailroot\Pickup
with From, To and Subject fields, it is dispatched immediately to the destination email address with the correct sender.
Then, I have a framework generating my ASP NET C# web application ad when it tried to send an email with:
IDMailer v_M1 = null;
v_M1 = (IDMailer)new IDMailer();
v_M1.FromAddress = (new IDVariant("allegretti#er-go.it")).stringValue();
v_M1.AddToAddress((new IDVariant("lorenzo.vinci#conservice.it")).stringValue());
v_M1.Subject = (new IDVariant("prova")).stringValue();
v_M1.HTMLBody = (new IDVariant("<b>ciao!</b>")).stringValue();
try
{
v_M1.SendMail();
}
catch (Exception e3)
{
MainFrm.set_AlertMessage(new IDVariant(e3.Message));
}
then I have an error in sending the email which fails. I have tried also both the following settings in the application pool of my web application:
and they both fail with these error messages:
Thursday, October 6, 2016 - 5:38:09 PM
Failure sending mail.
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at com.progamma.IDMailer.SendMail()
DTT_LEVEL=5
DTT_MSGLEVEL=3
DTT_LEVEL=5
DTT_MSGLEVEL=3
Failure sending mail.
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at com.progamma.IDMailer.SendMail()
The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available
at System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
at System.Web.Mail.SmtpMail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
at com.progamma.IDMailer.SendMailSSL()
--------------------------------------------------------------------
Thursday, October 6, 2016 - 5:38:25 PM
Failure sending mail.
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at com.progamma.IDMailer.SendMail()
I have no idea why this happens but I really need to correctly set up a SMTP server in our Windows Server. I had tried to use Google smtp server as realy and it was ok but it did not allow us to set an arbitrary sender email address but only the one of the account used to connect to gmail smtp server. That's why I need my SMTP server because sender anddress will vary according to the user logging into the web application.
How can I solve this?
Maybe does this happen because the web applicaion is installed inside drive D (which has its own pickup emailroot directories) instead of C drive?

Syntax error, command unrecognized. The server response was ''

I've looked at 3 or 4 questions here so far and they haven't helped yet.
I have set up SmarterMail 14.x on a client's machine. I know very little about setting up mail servers (I don't know why he thinks I do) but I have it installed, a domain set up pointing to the MX record, the port open (9998) and I am able to send email just fine from the web interface.
However, I can't send email from Sql or from C#. I created a quick and dirty app to allow me to enter the server, port, credentials, and to/from and I get this response every time:
[Inner Exception]
Unable to connect to the remote server
[Details]
System.Net.Mail.SmtpException: Failure sending mail. ---> > System.Net.WebException: Unable to connect to the remote server ---> > System.Net.Sockets.SocketException: No connection could be made because the > target machine actively refused it 204.12.49.188:25
I've tried multiple logins. I've also confirmed that SMTP is turned on and IMAP/POP3 is turned off. I'd post images of it but unfortunately I can't yet.
The code to send is below and it is about as simple as it gets:
SmtpClient client = new SmtpClient(ServerTextBox.Text, Convert.ToInt32(PortTextBox.Text));
NetworkCredential login = new NetworkCredential(UsernameTextBox.Text, PasswordTextBox.Text);
client.Credentials = login;
MailMessage message = new MailMessage(FromTextBox.Text, ToTextBox.Text, "Wine and Spirits Jobs Alerts", "Below are this week's job alerts: There are no job alerts at this time");
client.SendCompleted += HandleSendCompleted;
client.SendAsync(message, null);
I've also tried it locally on their VPS and on my machine. I've turned on and off the firewall and I've got a specific rule allowing outgoing traffic on 9998 (and you can log into the web interface remotely) so this isn't a matter of being able to contact it.
I'm at a loss of what to do. If someone can help??
EDIT: It's clear I was using the wrong port - 9998 instead of 25. Using port 25 now tells me either time out or that it was actively refused. The firewall does have specific rules for port 25 that allow all traffic, so it shouldn't be stopped.
EDIT 2: I've re-created the MX record on the domain and ensured it is pointing to the correct IP address. I've also re-created the domain in Smartermail and made sure SMTP is turned on, authentication is required, SSL is not, POP and IMAP are turned off, and that my login is correct. I've also tried turning on and off the firewall. No dice.
I finally solved the issue.
It had nothing to do with firewalls or the MX record or using/not using an IP address and everything to do with the fact that while port 25 was indeed assigned to SMTP and SMTP was indeed turned on, the IP address of the domain itself was NOT assigned to the SMTP configuration so SmarterMail wasn't actually monitoring the port.
Problem solved - email sends. Fun stuff! Thank you for everyone's responses!
Try setting SMTP mail server IP address in your mail sending code.
SmtpMail.SmtpServer = "your mail server name or IP address goes here";
SmtpMail.Send(Message);
Your can set this property at global level or in any Initialization code.
Reference : https://msdn.microsoft.com/en-us/library/system.web.mail.smtpmail%28v=vs.110%29.aspx

SMTP : error relaying

i am creating an email client that sends e-mail address from server ip instead of SMTP , i wrote that code:
SmtpClient server = new SmtpClient("50.23.128.66");
MailMessage msg = new MailMessage("from#yahoo.com", "tome#yahoo.com", "subject", "body");
server.Send(msg);
but when i run it , i get that error:
Unhandled Exception: System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: 5.7.1 Relaying Denied.
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressColl
ection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
* By the way i am using Windows Server 2008 *
and i configured the smtp server to localhost and port 25 , but i don`t know what is that relying error .
If you are using you localhost to rely email, you should be using 127.0.0.1 or localhost instead of that ip address you posted in your code.
Relaying is the method the SMTP server uses to authenticate that it should route the email from a particular sender. An "open relay" means that there is no authentication and the SMTP server will send email sent from anyone. This is not a good practice and there are probably some mechanisms on this particular SMTP server to authenticates, such as a user name and password or even the IP address of the sender. Check with the administrator of the SMTP server to see what is required. I would think at a minimum you would need to set the user name and password, which you did not do in your code example.

Intermittent "The server response was: 5.7.1 Unable to relay" errors

I have a little C# email app that runs on a server. When launched it sends one email and then goes away. Most of the time it works fine, but every so often it will give the below error:
System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: 5.7.1 Unable to relay for joe123#msn.com
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at AppEmail.clsEmailMgr.SendEmail(MailMessage inMM, Int32 inTriesLimit, Int32 inSleepTime)
at AppEmail.clsEmailMgr.MainProcess()
I have looked at some other postings on this type of error, but they tend to focus on the server setup - which I think is correct - or else this app would never work... and most of the time it does.
One other note: This app can get called multiple times fairly rapidly, so there can be situations in which different instances of itself are trying to send emails at almost the same time. Could a SPAM filter be blocking some of the email sending attempts? Any other ideas would be appreciated.
This error occurs depending on the server setup... it does not prevent your code from working all the time... BUT it prohibits sending eMail with a sender/from with a domain not allowed and/or sending eMail to a domain not allowed... thus the mentioning of "relay" in the error...
Usually if you ask the server to send an eMail from a#b.com and the server is only setup for the domain c.com then this error comes up... otherwise it would be vulnerable to abuse by spammers (google for: spam open relay)... if your app needs to do such "relaying" for legit reasons then ask the mail server admin to configure the mail server that it allows relaying for the machine hosting your app...
Rapidly sending shouldn't be a problem except it could be perceived as an infected machine trying to send loads of spam... since you don't tell anything regarding the quantity per time unit this is pure speculation...
I faced similar intermittent issue (unable to relay) with one of my application. I verified the SMTP host log and the error recorded there was 'Auth login' failure. Finally, we tried passing the SMTP credential username in UPN (universal Principal Name) format to the SMTP client.
Example: Use username#abc.com instead of domain/username
This will give consistent result.

Temporary problems sending emails with ASP.NET

I hate to just post a stack trace here, but I am out of ideas... My app sends emails for various tasks on the website, and 90% of the time there are no problems. However, every so often ASP.NET throws a weird exception, which seems to relate to mail server connectivity (I use google business servers for email). The error is too generic for me to debug, hence the stack trace below. My app captures the exception and writes back a generic 'try again in 5 minutes response'.
I'm stumped by this error because:
Google email is generally very reliable (it is being sent from my domain, not gmail.com).
Volumes are very low, so this shouldn't be a loading/spamming type of problem.
Error is very generic.
Trying again in 5 minutes almost always allows the email to be sent with no problem, with none of the parameters (recipient, subject, body) having changed.
Any ideas? The only outstanding issues I can think of is that:
Email sending is synchronous. This is what I actually want to occur, as I want to respond to the user with a success/failure status message.
I am using Amazon EC2 as a server, if that has any bearing on the matter.
The code:
public static void SendMail(String from, String to, String subject, String body, bool IsHtml)
{
MailMessage m = new MailMessage(from, to, subject, body);
m.IsBodyHtml = IsHtml;
SmtpClient smtpClient = new SmtpClient();
smtpClient.EnableSsl = true;
smtpClient.Send(m);
}
The exception:
System.Net.Mail.SmtpException: Error in processing. The server response was: 4.3.0 Mail server temporarily rejected message. m6sm2190005vcx.24
at System.Net.Mail.DataStopCommand.CheckResponse(SmtpStatusCode statusCode, String serverResponse)
at System.Net.Mail.DataStopCommand.Send(SmtpConnection conn)
at System.Net.Mail.SmtpConnection.OnClose(Object sender, EventArgs args)
at System.Net.ClosableStream.Close()
at System.Net.Mail.MailWriter.Close()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
I've worked on bulk email systems in the past. The exception message you are getting is totally descriptive: that SMTP server is temporarily not accepting mail. This can be due to a number of conditions:
The server is busy
You are sending too many emails too fast (this can make you look like a spammer)
General errors
The fact that retrying the email later always works indicates that this is normal, expected behavior. There is nothing you can do differently to avoid this, it's a common method used by ISPs to throttle traffic when needed.
In addition to what Dave Swersky already said:
You could store the emails you want to send somewhere (like filesystem or database) and let the e-mail generation be handeld by a service. Your service would watch for new emails to send. If an error occurs while sending, you could put the e-mail back into the queue and try again later.
Maybe you can even use a local STMPServer that uses GoogleMail as relay server. It that case you could use the built-in pickupdirectory functionality instead of writing it yourself.

Categories

Resources