Reputation: 170
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
Upvotes: 3
Views: 2747
Reputation: 1039
It is possible to send mails without SMTP server directly through your code, i had already did this, but later after some months mail guard kind of things started to blocking my IP. just read this blog.;)
Upvotes: 1
Reputation: 4257
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);
Upvotes: 4
Reputation: 1039498
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.
Upvotes: 1