I want to check whether an SMTP mailbox is available for a given username and password. I am using the SmtpClient.Send method to send the email, but before sending it I want to check the whether the credentials provided are correct and also to check whether the SMTP server is valid.
How can I do this from C#?
I don't think the API provides the equivalent of an "is valid" type of query. However, when you look at the documentation, it states that an SmtpException will be thrown if the send fails; two of the reasons for failure include what you were looking for
invalid server (i.e. you couldn't connect with the SMTP protocol)
authentication failed (i.e. invalid username and password)
So handling that exception and inspecting it for whether the failure was indeed due to an authentication failure or a server connection failure should provide you with what you need.
Related
I am testing my application with PayPal sandbox.
The URI I use for the transaction is https://sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick.
In my return page I read the data from PayPal then I form a new string to send back with cmd = _notify-validate.
When I make a call to https://sandbox.paypal.com/cgi-bin/webscr I am getting error saying "The remote certificate is invalid according to the validation procedure."
I tried making a call to https://www.paypal.com/cgi-bin/webscr instead and it always return t "INVALID".
This appears to be an SSL issue: This error message is caused because the process is not being able to validate the Server Certificate supplied by the Server during an HTTPS (SSL) request. The very first troubleshooting step should be to see if the server supplied certificate and every certificate in the chain is trouble free.
I am getting 555 syntax error in mailfrom
SendData(tcpSocket, string.Format("MAIL From: {0}\r\n", MailFrom));
if (!CheckResponse(tcpSocket, 220))
{
tcpSocket.Close();
return false;
}
is it the problem in my local system because of localhost?
Please help me. I am using this code from below link.
http://www.codeproject.com/Articles/5189/End-to-end-Email-Address-Verification-for-Applicat
Please don't try to implement your own SMTP client, use the one that comes with .NET: System.Net.Mail.SmtpClient.
Many SMTP servers require TLS, for example, which your code does not account for.
Furthermore, for security reasons most mailservers will not reveal if an email address in an RCPT TO line is valid or not. If a system can positively reveal an address exists then it can be used by spam harvesters. Consequently using a dry-run of an SMTP client should only be used to validate an email address (because of the complicated rules regarding valid email addresses). The verification (a separate concept from validation) must be performed manually by requiring the user to respond to an email sent to that address, there is no other way to be sure.
In unrealscript, I'm attempting to connect to server using a TCPLink client I wrote. I can connect to the domain, but when I attempt to access a welcome message I receive a 401 error. What am I doing wrong in my authorization field?
Note: username and password are plain-text string variables filled in by the user
SendText("GET /crud/welcome HTTP/1.0"$chr(13)$chr(10));
SendText("Host: "$TargetHost$chr(13)$chr(10));
SendText("Authorization: "$USERNAME$":"$PASSWORD$chr(13)$chr(10));
SendText("Connection: Close"$chr(13)$chr(10));
SendText(chr(13)$chr(10));
You may want to read RFC 2617.
I've been getting the following exception when trying to send an e-mail using System.Net.Mail:
Unhandled exception in Service Thread:
System.Net.Mail.SmtpException: Mailbox unavailable. The server response was: Requested action not taken: mailbox unavailable
at System.Net.Mail.DataStopCommand.CheckResponse(SmtpStatusCode statusCode, String serverResponse)
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)
Does anyone know what this could be caused by?
This is actually an error code returned by the server you're attempting to deliver to. Usually it means the email address you're attempting to deliver to is invalid, or their mailbox is full and isn't allowed to receive anymore mail.
Either way, this isn't a problem with your code, it needs to be resolved by the admin of the mail server. (I guess unless you chose to send the mail elsewhere)
I believe this just means that the recipient's mail server retuned the response "Mailbox unavailable" i.e. the address does not exist or something along those lines.
The SMTP server is returning an error saying Requested action not taken: mailbox unavailable. Check with the SMTP server and make sure that email address can receive mail.
I'm running a WCF client locally that always throws a MessageSecurityException with the text:
"An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail."
The Inner Exception Message Is:
"An error occurred when verifying security for the message"
I set up a trace and in that file I can see the "inner inner" exception message as:
"The 'Body', 'http://www.w3.org/2003/05/soap-envelope' required message part was not signed. "
The bindings all match perfectly between the client and the service with them all using netTcpBinding with the securityMode="Message".
The ServiceContract decorating the interface behind the service is:
[ServiceContract(ProtectionLevel = ProtectionLevel.None)]
What could be causing my errors? I'm no WCF expert so I if you need anymore information just comment. Any ideas on what to try would be helpful too, I just have no idea whats going on here.
By default, all messages are signed and encrypted in WCF, and why on earth would you ever want to turn that off??
So in this case, most likely, your client has encrypted and signed the message, but the server doesn't understand it because of your attribute on the service contract.
My recommendation: unless you have a very compelling reason, never tamper and change those settings - just forget about that attribute on your service and leave the defaults:
[ServiceContract(ProtectionLevel = ProtectionLevel.EncryptAndSign)]
or
[ServiceContract]
If you really have to turn it off, you need to turn it off on both sides of the conversation - both the client and the server must agree on whether or not messages are encrypted and signed.
Marc