Last post Jan 14, 2020 05:23 PM by PatriceSc
Feb 26, 2018 10:05 AM|qsoft_developer|LINK
I am building a new website for my company. At the moment we are using static website and I would like to convert it all to ASP.NET.
I have designed a nice bootstrap form, however I am having trouble with the contact us form.
In my old website I userd asp and the following object:
Set Mail = Server.CreateObject("Persits.MailSender")
I tried implementing the following code:
However, I don't want to use a real 'from' email like this:
var smtp = new System.Net.Mail.SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
smtp.Timeout = 20000;
I just want to use the mail address that the viewer filled in the form, just I like I do now:
Mail.port = "25"
Mail.From = Request("email") ' From address
Mail.FromName = Request("first_name") & Request("last_name")' From Name
Is there a way to use the asp Persits.MailSender object with .net? Or maybe is there another simple solution?
Feb 27, 2018 06:39 AM|Cathy Zou|LINK
In Following article I will explain how to send email using Gmail SMTP Server in ASP.Net. To send email with Gmail SMTP Server, you will need to use an email address and password of a valid Gmail account and along with that you will need the Gmail SMTP Mail
Jan 14, 2020 05:23 PM|PatriceSc|LINK
And the old site was using Gmail as well ????
AFAIK it won't work. Technically speaking the mail is sent from the gmail account using your own mail account and GMail overrides "From" so that you can't forge mail that seems to originate directly from any address you want...
Using could perhaps work: https://docs.microsoft.com/en-us/dotnet/api/system.net.mail.mailmessage.replytolist?view=netframework-4.8
It is an additional info that can be used when a mail comes from an address but when the response should be sended back to some other mail address.
Edit: it's really a form with multiple fields? If you have just a body input field you could also use https://www.rapidtables.com/web/html/mailto.html (if public it's common to use js to prevent
spammers to collect your mail address straight from the html markup).