According to this answer it is possible to configure IIS to receive email. That is what I would like to do. But the answer says it's done under IIS SMTP under domains.
I connected to my website (on a web host) using IIS Manager and the only SMTP option I see is SMTP E-mail under the ASP.NET heading. (I have one more heading which is IIS, but doesn't have any SMTP under it.)
Clicking on SMTP E-mail shows me an option to "Use this feature...when sending e-mail...". and it has a textbox for E-mail address and radio buttons to choose from Deliver e-mail to SMTP server and Store e-mail in pickup directory.
I don't see any option for allowing it to receive emails.
So where is the option to receive emails?
(If you have a different way to receive emails without any action taken on them, I'd be glad to hear about it. I want to process the email regardless of the address it's being sent to as long as it's to my domain.)
You need the IIS 6 manager for that - even if you have IIS 7-8-9-10 installed. The SMTP part is still only in IIS 6 :(
It's not problem to run them side-by-side and you will use IIS 6 manager only for SMTP
With this option you could send and receive emails.
The IIS 6 manager looks like this:
And with you Windows system you need to install the SMTP server:
which give you IIS 6 (SMTP only)
See also https://www.interserver.net/tips/kb/how-to-setup-and-configure-smtp-server-on-windows-server-2008-r2/
And http://www.vsysad.com/2017/05/install-and-configure-smtp-server-on-windows-server-2016/
and see also How to configure SMTP in IIS 7?
I have a scenario where I wanted my web application to accept inbound emails and process them. I didn't find the SMTP server that comes with IIS to be helpful.
What ended up being a much better solution for receiving mail messages for me was to use an inbound email parsing service. You configure a domain's MX record to point to their (parsing service provider) mail server and their mail server parses the message and Posts to a page on your web server. My ASP.Net MVC Controller Action looks like this:
public ActionResult InboundMessage(FormCollection collection, HttpPostedFileBase attachment1, string attachments, string to, string from)
They get the email and call my code. I don't have to worry about any of the SMTP details. I've been using this for several years and it's worked great for me.
I'm not sure how recommending a specific product goes over around here, but if you Google "inbound email parser", you'll find several options.
If you want to go the original route, it is possible to receive inbound mail. It will write incoming messages to the "Drop" folder. (If you Google "IIS SMTP Drop folder", you will find information about how to do this.)
Before I found the Inbound Parse service, I ended up cobbling my own mail server together from some code on found on GitHub, but even then, parsing the parts of a message was a much bigger undertaking than I was expecting.
Related
EDITED :
I am quite new in this and I found out that when you send an email to patrick#fish.com the mail is sent to the ip address of fish.com and whatever server is hosted there should do the work of redirecting or processing the mail.
I have a web role (website) on azure which holds the content of myweb.com .
The thing is, I do not know how to configure the re-direction on that server. I know you could add an MX record on the server but azure does not give me that option since in azure there is a load balancer exposing the public ip and we have no access to it.
I do have a mail relay service which I hired to redirect the email but I dont know where to configure the re direction on azure.
Maybe there is a way to configure this in web.config inside the visual studio solution?
Don't use direct SMTP. You will have much better results with a service like SendGrid.
Microsoft has a special deal for free SendGrid service (<= 25,000 per month) for Windows Azure customers, so there's no reason not to use it.
http://www.windowsazure.com/en-us/develop/net/how-to-guides/sendgrid-email-service/
Redirection and MX records don't have anything to do with Azure - you setup MX records to handle your mail where ever your DNS is hosted.
In order to redirect a mail with webrole on Azure you either
have to configure DNS so that the mailserver is located somewhere
outside of Azure, or
receive the incoming mail and send it further to
a new recipient.
The first approach has nothing to do with Azure.
The second approach is not possible, for even though you can send a mail from your service by using SendGrid, as it was pointed out by Matt Johnsohn, there is no possibility to host an SMTP server in your webrole. Webrole itself is hosted within IIS and the latter provides its own bindings for SMTP, FTP and some other protocols. You can host a WCF service within your webrole instance that would use net.tcp binding for connection -- but you will not be able to bind the port 25 required for standard SMTP connection.
I have an MVC3 web application written in C#. I am using McvMailer to send emails from within the application, which is all working fine.
The issue i have is that our smtp server is not anywhere near the web server that will be hosting the application, and that it is possible that on occasion the smtp server may not be available.
I need to be able to detect whether or not the smtp server is available before giving a user the option to send emails. Thus far the best i have come up with is to ping the smtp server using the solution from #John Leidegren answer in this post.
However, it appears that the router is responding to the ping and not the smtp server. Baring in mind that the main cause for the server not being available would be the internet connection failing, i could probably live with this solution if i had to, but it would be nice if i could ensure the availability of the smtp service prior to attempting to send emails.
Any ideas?
Yes, ping is a good start, but to determine if the SMTP gateway is available, issue the HELO command through the SMTP port.
I'll try to find a good example.
Edit:
You're in luck. Here's a complete TELNET client written in C#. https://www.nuget.org/packages/Telnet
I have two servers one linux server running cpanel/whm which act as a mail server and DNS Server for my domain and I host the website for the same domain on a different windows web server.
I have set up windows server with SMTP service to be able to send emails from my ASP.NET application.
Everything is going OK and my application sends emails correctly everywhere except to my own domain itself. If I sent and email to an email address like this somename#mydomain.com it is never delivered although sending emails using the same application to any domain succeeds.
Could you help me what should be the reason for this problem?
Regards,
Ehab Zaky
This is most likely caused by a setting on your SMTP Server itself.
Most smtp servers by default will not accept traffic if it claims to be from a local domain but is not a valid local user. So the first thing I would try is send the email from something that is a real working email address configured on your SMTP server. If that works, then you know what the problem is and can choose your course of action from there.
If that doesn;t work, then I would check the security settings of your SMTP server and look for limitations / restrictions regarding local domains. I am not a Linux user, but this seems to me to be whats probably happening.
Dave
Im looking to send email vi a .net 3.5 form (C#)
Ive seen a few posts elsewhere and got the thing running ok for certain addresses but not for others, eg gmail accounts.
The finished app will have to pick up addresses from a database so Im having to cater for a lot of possibilites.
Im not looking to have my work done for me, just a shove in the right direction would be cool!
thanks
DD
Is it possible the gmail accounts are blocking you as a spammer? If you're sending out a lot of emails, or if there is a configuraiton issue on your server, they may have blacklisted you.
If the emails are going out from your server OK, but not reaching ALL of the recipients but is reaching SOME, then there is likely an issue outside of your direct control. An email goes through several servers in between your server and the enduser's inbox (and that's the case even if the inbox is on google's server for gmail.)
That said, there are things you can do to reduce your likelihood of being blocked/blacklisted.
This is a good place to start: http://www.andreas-kraus.net/blog/tips-for-avoiding-spam-filters-with-systemnetmail/
and then here is where to go from there. (Sorry - it's just a google search, but I gave you the relevant terms, at least.) http://www.google.com/search?q=system.net.mail+blacklist+spammer&rls=com.microsoft:en-us&ie=UTF-8&oe=UTF-8&startIndex=&startPage=1
Finally, here's a very good resource with a cool URL. Perhaps the force will be with you if you learn these ways, young padawan.
http://www.emaildeliveryjedi.com/avoid-spam-filters.php
But getting back to your original question - everything you need to know about how to write code to send an email is covered here: http://www.systemnetmail.com/ It's the same for all versions of .NET from 2.0 on uo through the current 4.0.
And I'm sure you're already aware, but in case you're not, be sure you're familiar with the CAN-SPAM act. http://business.ftc.gov/documents/bus61-can-spam-act-compliance-guide-business
In addition to the great info from David Stratton...If you're certain that the gmail accounts are not receiving your emails, i.e. you've waited for sometime, checked the gmail spam boxes, and you've checked your SMTP server logs to ensure that Google is not sending any particular messages back to your SMTP server, then you may have run into a case of grey-listing / black-listing.
Black-listing can occur when a mail service has decided that the IP address of your mail server is a spamming server. It can happen under different scenarios, shared scenarios can be quite common.
One shared scenario: Let's say you recently acquired a new IP address, but it was recycled by your hosting provider from a prior client of theirs, who was a spammer. There is no guarantee that the IP address would be white-listed.
Another shared scenario: You're sending emails on a shared hosting website, where your SMTP service that you are using is shared with other clients of the SMTP service provider. It may be that one of those clients used the SMTP service maliciously or without following appropriate SPAM rules that gmail abides by.
Your best bet is to contact Google to commence a white-listing process. Providing you follow their requirements, they should eventually unblock emails originating from your service.
Is it possible to send an email in C# console, without needing and SMTP server?
Edit:
Why do I need another SMTP server? Can not I use my localhost machine as a server..?
Edit:
I just need to send an email from with my domain name, for example abc#mydomain.com
Is that possible? what do I need to do this in my C# program... I do not care about receiving emails, I just care about sending them....
Thanks
You don't have to depend on a local SMTP server if you don't have one. However, you will have to connect to a SMTP server anyway. Here is why.
You must achieve the following steps:
Determine what is the mail exchange servers of a given domain.
Connect to that mail exchange server and deliver your mail.
Those steps are normally done by your local SMTP server. Another advantage of your local SMTP server is that it will handle its queue and continue to try to deliver your email if it fail.
How to determine the MX records of a give domain.
I suggest you to have a look at this answer. Basically, you have to do a query on a DNS server to get the list of MX records of the domain name of the email address you want to send an email to.
How to connect to a mail exchange server
Well the answer will disappoint you. Exactly like you connect to your local SMTP server. Using the TcpClient, you connect to one of the mail exchange server you got at the previous step on port 25 and start the delivering process using the SMTP protocol.
The trick here is that you must handle multiple MX servers. They are usually listed with a preference. If the first one is unreachable, you try the next one and so on...
That is something your SMTP server can handle for you too.
If you really want to build that logic yourself, please have a look at the DirectSend method of the SmtpClient class of this open source project I'm involved in.
As #TomTom points out, the entire mail infrastructure depends on SMTP. What you can do is to skip the output (relaying) SMTP server and send the message directly to the receiving SMTP server.
To do that you need to create some kind of queuing mechanism (there is no guarantee that the receiving SMTP server can serve you when you try to connect) and that you can look it up.
MX records are entries stored in DNS servers and are used to find SMTP servers. You can find a article here with a MX lookup example: http://www.codeproject.com/KB/IP/dnslookupdotnet.aspx
However, I DO recommend that you install a local SMTP server and let it take care of the above mentioned issues.
Yes, Basically figure out where to sent the email and send it. i.e. a DNS MX lookup for the domain to find out the SMTP server.
Every email needs an SMTP server on the receiving side.
You can use gmail or yahoo SMTP server, if you don't want to install your own.
Before sending mail you first need to authenticate, otherwise sending mail is not going to possible.
You need access to some kind of email server to send your email, and your email will most likely pass through one or more SMTP servers on it's way to the recipient. However, the email server you connect to might let you send the email without using SMTP. For example, Exchange might let you use MAPI or CDO to send emails. Though I think that CDO is not officially supported by .Net and simple MAPI is deprecated in Windows and should not be used. You might be able to use Exchange Web Services as described here: Introducing the Exchange Web Services Managed API 1.0
If you have another email server than Microsoft Exchange, that server might have some kind of API you can use.
Something I do often is to create gmail account and send through that account.
You just need your SmtpClient to connect to the host smtp.gmail.com on port 587 with the username, password, and enableSSL property set to true.