I have question about sending emails from MVC3 application. I already read for exmple about ActionMailer.Net, I have seen a lot of forums and helpers from someone. Everywhere I saw SMTP server and its settings, for example in Web.config, or in appropriate method/function. Is it possible to send email without smtp settings? I am building application, which will be used by several users, I dont want to put them to need setting some SMTP...
I need to send emails like "Your password is xxxx, go to www.mysite.com, thank you." and so on. I dont need to have it in any mailbox (as history), I dont want reply for it.
Is there a possibility like in php where I use mail(...) function, without setting SMTP server, I can send from -> to what ever I want.
So am I bad understanding to something. Pleas help me to figue this out. Thank you very much
You have to have an SMTP server, otherwise you can't send mail via SMTP. The same is true with PHP.
Whether you need to have the settings depends greatly on your hosting. Most servers will have the SMTP stuff set up in a config file higher up the chain, so often you can leave the settings at their default, and ASP.Net will still be able to send mail using SMTP with no specific settings being necessary.
However, its also possible that your host will require you to use specific SMTP settings. That's something you'll need to check with the people who will be hosting your site.
If you need example code on how to send an email with minimal code, something like this should work, PROVIDED that your host doesn't want you to specify the settings:
var message = new MailMessage(FROM ADDRESS HERE, TO ADDRESS HERE)
{
Subject = "Please confirm your email",
Body = "PUT SOME BODY COPY HERE"
};
var client = new SmtpClient();
client.Send(message);
Is it possible to send email without smtp settings?
Of course that it is not possible. You cannot send an email without an SMTP server. This simply doesn't make sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With