I have a web application running on Windows IIS. This app has a database where each item has a unique key (1, 2, 3...), and a list of email addresses (among other things).
I would like users to send email to the server, using an email address that identifies the item, then have the server relay the message to the email addresses for that item. For example, if a user sends email to the following address:
item-75#myserver.example.com
Then the server would receive the email and pipe it to a script. The script would query the database for item 75 to get a list of email addresses, then re-send the email.
I could do this easily on a unix system using sendmail, but I have no idea if a similar setup can be accomplished on a Windows system (or if it would require additional software).
(This sounds like you want to implement a feature like craigslist).
The IIS SMTP service can send email, and also accept email.
Here is what you want to do.
Configure your IIS SMTP service to accept emails for a domain (You can configure this in the properties of the IIS SMTP service, under domains). Say domain name "myserver.example.com"
Then, in your DNS server, configure a MX record that points to "myserver.example.com".
Now, when email gets sent to your IIS SMTP server, it will actually get placed in your mailroot/drop folder (you can also change this folder in the IIS SMTP Service properties).
Now that you are accepting email, the next step is to write a script that will:
1)Parse the emails.
2)Modify them accordingly (do you just want to change the "to" address?).
3)If you want to resend the emails, then you need to modify them accordingly.
You will need to add a single X-Sender header, that is used to identify the email address sending the email, and a X-Receiver header, for each recipient that is going to accept the email. Here is an example email that was modified:
X-Sender: me#mywebsite.com
X-Receiver: recip1#theirdomain.com
X-Receiver: recip2#theirdomain.com
From: "jim bob" <jim#example.com>
To: <item-75#myserver.example.com>
Subject: test
MIME-Version: 1.0
Content-Type: text/plain;
Message-ID: <024f01c9e130$b3eca500$0401a8c0#local>
test
Once you have this modified content, you will want to write it to a file in the mailroot/pickup directory. Be sure to use a unique name.
The IIS SMTP Service will come by, pickup the email, and relay it on, sending the email using the X-Sender as the MAIL FROM address, and sending it to each email address listed in each X-Receiver header.
4)Run this script as a scheduled task. Another option is to build it as a windows service, or to implement something like a filesystemwatcher, where it executes each time an email is created as a file.
5)Another option to all of this is to actually implement a SMTP Event Sink, but I think that is overkill for what you want to do, and can create more headaches, than it solves. I would only go the event sink route if I like pain.
Hopefully I didn't make that about as clear as mud.
Event Sinks aren't difficult at all! In fact, there are about a dozen examples written in VBS (which runs on a Win server using WSH) which accomplish exactly what you wish to do. The OnArrival event sink runs in REAL-TIME using any computer user account you wish w/o any security risk since the message is asynchronous and doesn't report back.
This is actually a terribly easy thing to do - one of the easiest. Once set up, it never breaks either. On one server I've had one running for more than 9 years processing a few thousand incoming messages per day! I've set up about a dozen of these things - if it takes you more than a couple hours, you're doing it very wrong. If it were any easier than this on UNIX, my grandmother could be a UNIX programmer so I wouldn't go bragging that this is easier to do on a UNIX server.
http://msdn.microsoft.com/en-us/library/ms528023.aspx
http://support.microsoft.com/kb/894286
http://msdn.microsoft.com/en-us/library/ms526206.aspx
http://msdn.microsoft.com/en-us/library/ms526620.aspx
You could read in email through POP3 or IMAP using a timed script. I'm also a UNIXer so I'm struggling to comprehend how something like this is so difficult, but there you have it. Here's what I reckon you should do.
Make a script in whatever language you like. As long as it can read from POP3 or IMAP.
Have Windows run the script every 5 minutes
Have the script access the mailbox and action any emails it needs to.
My personal preference would be to install Python, but if you're limited... I don't know. ASPNET isn't bad, but I've never used it for dirty-scripting before.
Related
Java 8 here, although this really is more of a generic Exchange/SMTP question I suppose.
I purchased a domain name and Office 365 support from GoDaddy, and as a result, have several email addresses through them. Let's say one of these is support#myapp.example.com.
I am writing a Java 8 app that will allow users to send emails to this support address (through the app). I will likely use the excellent Simple Java Mail library, which wraps the Java Mail API. And so somewhere in my app there will be some code that looks something like:
Email email = EmailBuilder.startingBlank()
.to("MyApp Help Desk", "support#myapp.example.com")
.withSubject("Support Ticket #12345")
.withPlainText("Something went wrong inside the MyApp!")
.buildEmail();
Mailer mailer = MailerBuilder
.withSMTPServer("smtp.host.com", 587, "user#host.com", "password")
.withTransportStrategy(TransportStrategy.SMTP_TLS)
.withProperty("mail.smtp.sendpartial", true)
.buildMailer();
mailer.sendMail(email);
Pretty straight-forward stuff, right? Except I'm confused about one simple thing: which SMTP server am I using here? Would I use the Microsoft Exchange server that my GoDaddy account provides me, or would I choose something else?
That depends a little bit on what you want to do.
If you just want to make one attempt to send the mail, you connect to the mail server that accepts mail for support#myapp.example.com. It sounds like this is an office365 server owned by Microsoft that accepts mail for myapp.example.com. There should be public DNS records for that domain. I haven't used the Simple Java Mail library, but from your pseudocode, I assume it does the DNS lookups for you.
It sometimes happens that an application encounters errors when trying to send an email. For example, somebody could restart your app server in the middle of the smtp conversation, or reboot your router, or something else. It's pretty common to use a Mail Transfer Agent (MTA) such as Exchange to help make this process more robust. If the MTA fails on the first delivery attempt, it will retry delivery for some configurable period of time. In your case, you could send the email to your Exchange server, and it would route the email to myapp.example.com.
(In this case, Exchange is sort of acting as a Mail Submission Agent (MSA), but that's kind of a nitpick.)
Hope this helps.
I was setting up two new Exchange 2013 servers with MBX/CAS roles and added them to the existing send connectors that route mail through a smart host. Apparently the guy who quit before I started never got the networking team to whitelist the IPs for these servers. Now, I've got a small chunk of mail sitting here that won't send because of this. My networking team says that they can't do anything about it until tomorrow night. I'm afraid that some business critical mail may have got caught before I noticed what was going on. My question is, how can I re-route the mail stuck in these queues to go out through the send connectors from the previously implemented Exchange servers?
First of all, you should remove these servers from the send connectors to avoid more messages being stuck. You can either remove them from GUI console or by using cmdlet Set-SendConnector
Check here for more details about Set-SendConnector
Secondly, you should export those messages stuck in queue as .eml files by using Export-Message cmdlet.
Check here for more details about how to use Export-Message
At last, you can put all these .eml files under Pickup or Replay folder on any working transport servers. The transport service will pick up all eml files there and submit them to re-transport.
Check here for more details about Pickup and Replay folder
Closely monitor the queue and ensure all emails are delivered, then you are good!
I have a .Net application. I want this application to send an email to me. How do I implement this without installing an SMTP server?
Using an SmtpClient to send a MailMessage does not require you to have a server on your local machine.
Your e-mail service provider is the one with the server (e.g. smtp.gmail.com), and your SmtpClient talks to it.
This article by Peter Bromberg on eggheadcafe.com
C# SMTP Mail without SMTP Service or CDO
explains how to send email without relying on an SMTP client:
Sending email via TCP using the native
SMTP RFC commands "HELO", "MAIL From",
RCPT TO", etc. is no big deal. That's
one of the first tricks we learn with
Telnet. Finding or writing managed
code that will do so reliably is
another story. The code in the class
that follows is not my original code -
I've cobbled it together from three
different sample sources, fixing
namespaces, error handling, and other
minor items, changing console code to
class library code, and providing a
complete Winforms - based test harness
front end that illustrates its correct
usage.
I've also included sample code
to correctly process and add a mail
attachment via an OpenFileDialog here.
This code MIME encodes and transmits
the attachment(s) according to the
specification.
You can't send email without the services of a SMTP server, there is of course no need for you to install one, just point your code at your ISPs SMTP server or your companies Exchange server (or what ever they use).
I've just installed hmail on Windows 2012 to self host a mail server. Opened the ports (25, 143 - SMTP, IMAP). Setup auto reply on some test accounts on domain.
I have a strange experience: The first emails I send to the new inboxes from my gmail account get auto-replied. Thereafter any more emails sent are largely not replied (i.e. mostly not replied but occassionaly very late). The hMailServer logs show it found the emails and sending the replies. I tried with my work email account to the new hMailServer inboxes and its the same situation.
I've checked the spam and they only occasionally go in there depending on the auto reply message body. Reverse DNS has been setup by my cloud instance provider.
Not sure whats going on but the hMailServer diagnosis does show red lights against MX records not being found local and internet domains (although internet MX route checking sites give it a green light when checking).
Why is it only sending out first time and then less likely other times.
Ok its because the autoreply function only sends auto replies once per email address. I ended up applying a 'rule' instead to reply and delete the incoming the message to reach the desired behaviour.
The autoreply feature only ONCE per email address PER SESSION. That is to say, when hmailserver (service) is stopped and restarted the cache is cleared and so the first occurrence of the autoreply already sent is forgotten. (Note: it also doesnt autoreply to 'auto-reply' emails as this could cause looping)
I'm very new to Email server config field.
I have 10 000 Email address in my database. My only requirement is send a mail to each and every email address. But I do not need to receive any mail(not need static IP). I know it is not possible with common mails like Gmail or hotmail. How can I do it ?
I have tried SMTP. Installed IIS 7. When I going to config the SMTP it ask a email address. I believe that it is act as a client and foreword mails to real Email server.
How can I implement my own Email server in my machine ? Or if I use Linux kernel how the things happening ?
please help me.
Well... we're talking about sending a mailing, right? :]
Hey, it's 2012, where in the middle of SPAM war! I'm more than 100% sure that you'll waste lot of time and end up with noting or with your e-mail account blocked by your ISP for sending out e-mail. Because you will have to use your existing SMTP server / account for encrypted sendout or your own, local server will only be able to use port 25, which is blocked on most destination servers.
Want to know the best solution? Find any site (like freelancer.com), where you can offer a one-time job of sending your e-mail do these recipients and pay for it. This is the simplest, fastest and low-nervous way. And it should be fairly cheap for only 10k addresses (I found some Hindi company on freelancer, where I paid 10$ (ten bucks!) for a mailing to 500k+ addresses, though quality and time of doing this job was really poor).
I had the very same issue. I wasted few hours for trying to setup own mail server or use some specific mailing piece of software. I considered many solutions, waste too much time and ended up getting someone from freelancer.com to do the job for me and paid for it.
You can also consider a professional mail sending service, like for example MailChimp.
MailChimp allows you to send up to 12 000 e-mail per month absolutely free (as a demo of their paid services). But since you can have only 2k addresses in your address book per once, you would have to split your 10k database into five parts and send out whole mailing in five days long period. But still, free.