Perhaps I'm missing something obvious so please forgive my naivety I'm an app developer and web is still weird for me... The client desires a email page that sends its email body to his main email address for the site. Is this as simple as my creating a page for the user to enter their data return email address email body and then formatting that into an email. I can make the page (MVC 3) View and related controllers but how do I send the email to the address?? Am I over looking something very simple because its a website?? Any references links or insight is greatly appreciated thanks
Hope this helps I had a similar issue. I'm using ASP.NET (C#), here are relevant snippets: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Net; using System.Net.Mail; try { lblStatus.Text = "Sending Mail"; //create the mail message MailMessage mail = new MailMessage(); //set the addresses mail.From = new MailAddress(txtFrom.Text.Trim()); mail.To.Add("[email protected]"); mail.To.Add(txtFrom.Text.Trim()); //set the content mail.Subject = "SupportRequest/Comment: " + txtSubject.Text.Trim(); mail.Body = txtMessage.Value.Trim(); SmtpClient smtp = new SmtpClient("mail.yourdomain.whatever"); NetworkCredential Credentials = new NetworkCredential("[email protected]", "postmasteremailaccountpassword"); smtp.Credentials = Credentials; smtp.Host = "mail.yourdomain.whatever"; smtp.Send(mail); lblStatus.Text = "Mail Sent"; } catch (Exception ex) { lblStatus.Text = ex.ToString(); } NOTE: This code looks as simple as anything else, and is actually very similar to code that Winhost has published in the KB. But it failed at send. Just today I saw a reply to my post indicating I had to edit the trust level in my web.config. Good luck!
WOah Simple task I was hoping this would be a simple task... So I guess I will be looking up adjusting the trust level in a web.config.
We have a knowledge base article on changing your trust level in your web.config file. You can see it here: Changing the default ASP.NET Trust Level We also have a knowledge base article on How to send email in ASP.NET So basically. Use the mail server's SMTP service to send mail through your web application. Some people have found that sending with the [email protected] email account resolves any other issues. You also need to make sure you pass through the SMTP authentication process. Help this information helps