I have a "Contact Us" page where in users will give in their email id and a query and on submitting the form, web admin would receive that email.
If I configure their email id to "from" MailAddress and send the mail, it will fail to do so if the ID is from popular mail domains like gmail or hotmail but would work with other unpopular or non existent domains like [email protected] without any credentials provided!
It worked with gmail after I configured SMTP and network credentials properly. The aim is to let the admin of my website who receives the email be able to hit the reply button in his mail client and see the "to" field populated with the "from" field filled in "contact us" page. Is there any proper way to do this or a tip or trick to accomplish it.
Heres my code
MailMessage emailMessage = new MailMessage();
MailAddress emailTo = new MailAddress("[email protected]", "Web Dev");
MailAddress emailFrom = new MailAddress(tbEmail.Text);
SmtpClient localhost = new SmtpClient("localhost");
emailMessage.To.Add(emailTo);
emailMessage.From = emailFrom;
emailMessage.Subject = "Enquiry / Feedback";
emailMessage.Body = "Name: " + tbName.Text +
"\nAddress: " + tbEmail.Text +
"\nComments: " + tbComments.Text;//emails body
localhost.Send(emailMessage);
Thanks
Sid
Not sure why you've got problems here -- we've got a few systems that do just this without any issues. But mail is a finnicky and hinky beast; I would bet on a configuration setting on the server messing things up -- how much control do you have there?
In any case, the more proper way to do this is use the EmailMessage.ReplyTo (2.0/3.5) or EmailMessage.ReplyToList (4.0) property to send the messages. This will probably bypass any configuration on the server that is causing this problem.