The
SmtpFailedRecipientException
pretty much states that in it's current state that this email cannot be deliver to the recipient.
You would be most likely get better results if you added a specific catch for this exception and review the
Message
property or any
InnerException
. Here is a simplified version; they key with
"stacked" catches() is that the generic
Exception EX needs to be last as it will catch any exception that hits that line
try { }
catch (SmtpFailedRecipientException SX) { status.Text = SX.Message; }
catch (Exception EX) { status.Text = ex.StackTrace; }
I do find your code a little different than most contact forms; usually the to/from are hardcoded to prevent the form from being for nefarious purposes. This could actually be causing the problem if the network credentials being used do not have permission to send on behalf of the from address being used. Google is pretty tight on enforcing the rules.
Another common issue when using gmail is that the account being used must have the
Allow less secure apps... setting be in the on position.