I'm hoping for an event based way to know when I get an email. Right now I'm using gmail but the email host isn't critical. Do I really have to poll it?
You could forward the mail to a *nix host that uses .forward files, then pipe the mail to a script that handles raising the event in your program (by pinging a URL, etc.)
Here's an example in a CPanel/PHP environment: http://kb.siteground.com/article/How_to_pipe_an_email_to_a_PHP_script.html
If you connect to gmail using IMAP, you should be able to use the IDLE command. Gmail's IMAP server does support IDLE.
RFC 5465 proposes a NOTIFY extension to IMAP. It is unlikely that many servers implement it, though.
I've had bad luck with IDLE on both GMAIL and on Dreamhost (which uses courier). Exchange does a great job with IDLE though: I see mailbox updates in less than a second.
Without good IDLE support, yes, you need to poll.
Related
can I send an email through a PHP mailer with my localhost without using Gmail? or any other email service like Hotmail, outlook using my localhost?
Yes, and this is actually the best way to send using PHPMailer. There are two things you need:
A hosting provider that permits outbound SMTP. A large number of providers block SMTP by default, but you may find that they will remove the block on request (scaleway.com), provide an alternative service (AWS), which may also be acceptable.
A locally installed mail server. If you're on Linux, something like postfix is a good choice.
The way it then works is this:
Write your PHPMailer script as normal, but delivering to localhost over SMTP (not via mail())
Configure your mail server to act as a "full" mail server, where it attempts to deliver messages directly, or to act as a "smarthost" to relay through some other service, such as gmail or mailgun.
The main advantages of this approach are:
Perceived performance: your message submissions will appear to be instant, so it's great for things like contact forms
Reliability: if your message can't be delivered immediately, the local mail server will automatically take care of queuing and redelivery attempts, in a way that is far more efficient than you would ever achieve if you handled that within your own application.
As with many things, with great power comes great responsibility, and you will have to deal with bounce handling, blacklisting, inbound filtering (or just block it), etc. It's probably not worth doing all this for a simple contact form, but if you have an application that generates a reasonable amount of email traffic (signups, password resets, notifications, etc), it's a great way to go.
I am creating my Own Email Client Application using nodejs.Nodejs will sit between my Client Application and IMAP Server.
I am using node-imap module from Nodejs. It is designed to monitor only one mailbox at a time. But i supposed to monitor all the mailboxes available from IMAP mail Server.
I am using IMAP IDLE concept here. AS per RFC, IDLE only applies to the selected mailbox, thus requiring an additional TCP connection per mailbox. But i want to monitor all the mailboxes without using any additional TCP connection using NOde js Cluster concept simultaneously...
please help me out...
You can't do that. That's what NOTIFY does and I bet the server you're using doesn't support NOTIFY.
I have seen many of the posts relating to sending email under linux but they do not address my particular need.
I want to implement code (C/C++) in my linux application that will send me back some kind of notification (in a stealthy way) under a certain program condition. All it needs to send me is less than 50 bytes of status data. The only thing I am guarenteed is that the box will be on a local network which will have access to the Internet via the usual gateway.
One possibility would be to send me a text to my wireless carrier like this:
mynumber#verizon_gateway.com. But that assumes that I have a mail client available on the linux box which is not a guarantee. If I programmed this at the socket layer directly using SMTP I would have to manage a TCP connection which is not what I prefer to do.
Any suggestions of what would be a possible way to send me a notification from my linux app?
Thanks,
-Andres
For email you could use something like SendGrid, specifically their WebAPI - this will allow you to send email with only a HTTP request.
For SMS you could use something like Nexmo, which will allow you to send an SMS with a HTTP request.
Note that you'll have to include your API credentials in the compiled code - a potental security issue (for your credentials).
Disclaimer: I do a bit of developer evangelism for Nexmo.
I am trying to add email notification features to my Restlet server. I just learned today from Stackoverflow that Java Mail is synchronous.
So there are two obvious options: 1. use a really fast SMTP server 2. make it Asnyc
Well synchronously calling SMTP servers always introduce more delay. And since I'm simply using Java SE, no fancy EE stuff. What I am thinking about is initializing a new thread for sending the mail, however, things get much more complicated when I actually want to send the response from the mail server to web client to confirm mail is being processed by mail server, as I'll have to wait for thread to get a response.
Kinda confused right now, can anyone kindly offer suggestions on how I can do it with Java SE?
Server: Ubuntu Server 12.04
Java SE offers concurrency functionality for delegating work into seperate threads see java tutorial
Is there a way to peek or see a message before it hits the SMTP on IIS. This is not an Exchange Server, it's just running SMTP. I am trying to see if I can look at the message and then pass it to SMTP?
Thanks
Edit ~ Instead of adding another listner, I am wondering if there is a way to bind to the default SMTP listner and intercept the message then pass it on.
2nd Edit~ Ok, here is my problem. I have a spam filter in front of my exchange box, unfortunately (due to software design) the filter is limited when it comes to "Directory Harvesting Loookup". This is the process where the email addresses are checked if they exists in AD and the mail is dropped if they don't. My current filter drops the mail if one of the addresses does not exists in AD which is not good. I spoke with the vendor and there is nothing they can do at this time. I am looking put an app in front of this filter which would intercept (open, read, parse) the mail, validate the addresses, and then pass on the email to the filter for additional scanning. I'll then trun off this feature in their software. Don't get me wrong, their filter works great with this one exception which I must fix since I have tons of emails send to nonexistent users in my domain.
You can write your own Proxy SMTP service that you connect to to send messages. You can forward all messages directly to your actual SMTP service and pass all responses back. Then you can evesdrop on all these messages and deal with them accordingly.
Might be a bit overkill for what you're after but it's fairly simple to code as you dont need to know anything about the protocol as all you're being is a proxy.
If you're using .NET 2.0 then you can log SMTP sessions to a file:
How do I create a log file of the SMTP session? (System.Net.Mail)
Updated:
Take a look at this question:
Testing SMTP with .net (Stack Overflow)
From your edit:
"I am wondering if there is a way to bind to the default SMTP listener and intercept the message then pass it on?"
...and from your comment below:
"I am looking to inspect the actual message before the SMTP gets it."
I'm not sure if you fully understand the SMTP protocol. SMTP messages aren't just monolithic fire-and-forget entities. SMTP is session based and there is a conversation between client and server, of which, the message is just a part. The tracing method (linked to above) will record the entire exchange between client and server and does intercept the whole message before passing it on. The alternative, a proxy or mock server, will still require your application to engage in the SMTP client/server exchange. The closest solution to your requirement would be to use something like Papercut which is linked to in the answer above.
Kev
In .Net you can tell the SmtpClient to send email to a different folder than the SMTP service is monitoring. That way you could check each message, then move it to the real pickup folder. (See SmtpClient.PickupDirectory)
IIRC, you can still write up event sinks for the IIS SMTP service (even though it's not full blown exchange). It's been many years since I've done this, but you may want to google for "exchange event sink" to see if that helps.
Seems like a something like Ethereal will let you accomplish the sniffing portion of your request. Its not clear to me what you mean by "intercept" and "pass on". Do you want to filter some traffic or just delay traffic long enough for you to inspect before you pass it on, or both?