We have a system that can send emails using TLS. However, we only want to send full email w/attachments if the destination supports TLS. IF it does not support TLS, we send a different message without attachments.
We used to just try sending with TLS and waiting for the receiver to "fail" back to us, then send the backup message. Recently, we switched to relaying through Frontbridge for all of our outgoing messages. However, Frontbridge will send a message using TLS if it can, or without if it can't. We've lost the ability to customize our message based on TLS support.
The question is this: in a .NET C# web app, how can I tell if a destination supports TLS BEFORE sending anything? That way we can customize the message BEFORE relaying it through Frontbridge.
I need to be able to do this programmatically, but I don't want to have to add a whole library to our solution (like Minimalistic Telnet), because we don't need full telnet functionality... I just need to ping to server and ask it what it supports!
Can that be done simply using the System.Net.Sockets stuff??
Thanks,
Kevin
Yes, you need to write part of SMTP protocol.
For explicit TLS mode: You connect, receive and send data, then send STARTTLS command and see if the response is 220. Then you should close connection.
For implicit TLS you would need to emulate or use an SSL/TLS client: send initial request, check the response and disconnect.
As you don't want to use external libraries, I can't recommend you our SecureBlackbox, whose SMTP component lets you do what you need in a dozen of lines of code.
Related
I use Thunderbird with an IMAP server to access incoming email as well as for online storage of mail, and SMTP server for outgoing email. Every time I send an email, it first sends it via SMTP and then uploads it separately to my IMAP server's Sent Items folder. This is not only inefficient, it's also risky as sometimes, on a poor-quality connection, I can send out an email by SMTP but then fail to save it on the server with IMAP, leaving me without any copy of the email I sent (and Thunderbird doesn't save it in the outbox in such cases).
Is there any way I can set up some local and/or server-side software such that (1) the mail only needs to be uploaded once and (2) it will reliably appear in my Sent Items immediately, without delay (and without requiring it to be re-downloaded) and then also hopefully (3) when my connection is poor and an email can't be saved to the IMAP folder, it automatically stays in my local outbox until properly sent and synched?
Local mail clients have been around for so long now, I am really surprised that there appears to be no solution for this! Seems like webmail is the only robust solution, but that's no good for poor quality connections either.
I am thinking of solutions like offlineIMAP and dovecot, but wondered if anyone has got/seen an outline for how such a setup could be organised?
This is not possible using imap, the protocol just don't manage at all the sending of messages.
You could manage to do that using sieve scripts while telling postfix to deliver the message to the sender but that won't be robust and would save the email two times in the Sent folder if the client is not configured for your liking.
Overall, this is a bad idea.
From https://en.wikipedia.org/wiki/Internet_Message_Access_Protocol#Disadvantages:
"Unlike some proprietary protocols which combine sending and retrieval operations, sending a message and saving a copy in a server-side folder with a base-level IMAP client requires transmitting the message content twice, once to SMTP for delivery and a second time to IMAP to store in a sent mail folder. This is remedied by a set of extensions defined by the IETF LEMONADE Working Group for mobile devices: URLAUTH (RFC 4467) and CATENATE (RFC 4469) in IMAP and BURL (RFC 4468) in SMTP-SUBMISSION. POP servers don't support server-side folders so clients have no choice but to store sent items on the client. Many IMAP clients can be configured to store sent mail in a client-side folder, or to BCC oneself and then filter the incoming mail instead of saving a copy in a folder directly. In addition to the LEMONADE "trio", Courier Mail Server offers a non-standard method of sending using IMAP by copying an outgoing message to a dedicated outbox folder.[18]"
I like the idea of a clever IMAP server that handles handing off a message via SMTP through the use of an outgoing message folder, which the Courier Mail Server seems to be doing.
The set-up would need a 'smart' local SMTP server (defined below) as well as either a normal online IMAP server or else alternatively a local/offline IMAP server capable of keeping local offline copies of everything and synchronising when connected.
The 'smart' local SMTP server would need to handle the job of arranging for the message to be sent. In one configuration, it could simply do this as normal. But in another configuration, it could communicate with a 'smart' remote SMTP server, and, instead of sending the outgoing message to that server, it could tell that other server that the remote IMAP server has whatever particular message and, then the remote SMTP server could fish out the message from the remote IMAP server and send it on its way.
Such a configuration could be managed without a special email client. The only change from a standard configuration would be (1) setting IMAP to save sent messages in an 'outgoing' folder, and (2) setting the SMTP server to the 'smart' local SMTP server instead of the normal remote SMTP server.
None of this exists, but it could be implemented fairly easily by someone who was comfortable with both SMTP and IMAP protocols and server implementations, right?
Let's suppose I have created an IMAP client and I want to create a filter that, say, deletes messages that have certain characteristics.
I can make this a startup task that happens whenever the client is opened, but the problen is that a user might view the inbox in a different client and the filter won't get rid of the unwanted messages before the inbox is viewed.
Is there some way to tell the server to call my service every time it receives a message so the unwanted messages can go away once the server receives them instead of once a client is opened? Is this even possible with IMAP? If not, is there a different well supported e-mail technology that allows this sort of interaction?
You can do server-side email filtering with the Sieve Email Filtering Language and the ManageSieve Protocol. There is good support in open-source software. However, I am only aware of a few major email providers, that support it. If it is supported, it is usually accessible on the IMAP host and with the IMAP account credentials, i.e. you can test it by connecting to TCP port 2000 and 4190.
See the following three links for more information:
http://en.wikipedia.org/wiki/Sieve_%28mail_filtering_language%29
https://www.rfc-editor.org/rfc/rfc5228 (Sieve: An Email Filtering Language)
https://www.rfc-editor.org/rfc/rfc5804 (ManageSieve Protocol)
Sieve also supports a few notifications types. If the filtering language is not powerful enough to for your purposes, you can send notifications for all incoming emails, wake up the IMAP client, and let the client to the filtering.
I've a question regarding the over all design of push email and specifically the approach taken by Exchange ActiveSync.
As I understand there are two basic ways to get push email with the following architecture
Device <---> Push Email Server <---> Actual Email server
Keep a constant socket connection between Push email server and device. Push email server will inform device over the connection.
Related technology - IMAP IDLE
No sms gateway required
The Push email server will send a message (wap push, sms etc) to ask device to download new email.
Related technology- OMA-ENM
Needs a SMS gateway at Push email server
Considering this, what type of push email service does Exchange Activesync actually offer?
(AFAIK, white label push solution from Emoze/Synchronica uses the 1st approach - constant connection over something like IMAP-IDLE).
Exchange ActiveSync uses Direct Push. The client (phone, whatever) syncs with the Exchange server and then makes a very long-running HTTP POST request (called a "PING", but it's not an ICMP ping or anything like that). When the client issues the request they specify how long it should run for (typically it's on the order of many minutes).
That HTTP POST request will sit there idle on the Exchange server's side until either a change occurs in the mailbox or the time period requested by the client had simply passed with nothing of interest happening.
In the case of the former - where something changed in the mailbox - the return value of the POST call indicates to the client that it needs to re-sync with the mailbox to pull down the latest changes.
In the case of the latter - where nothing changed at all - the return value specifies this and the client simply re-sends another long-running PING to the server, repeating the whole process again.
So it's your #1, really. For more information, this Microsoft link goes into more detail.
I think Exchange ActiveSync offers something similar to IMAP-IDLE, see below...
http://technet.microsoft.com/en-us/library/aa997252.aspx
If you've come to a different conclusion please post. Thanks!
When I use Mac Mail to send a message, it has a received header included in it. Even though I'm running my SMTP through a remote server, my IP shows up (where it's 123.123.123.123).
Received: from [123.123.123.123] (host.of.my.ssh.tunnel.com [x.x.x.x])
I've seen many messages where it says:
Received: from my.own.domain.com (host.of.my.ssh.tunnel.com [x.x.x.x])
Is there any way to change [123.123.123.123] to my.own.domain.com in Mac Mail?
Leaving aside my concerns about why you want to hide this data, it's not your Mac Mail program that's inserting this data, it's the remote mail server, so unless you control that server and what data it puts into the headers, you're out of luck.
If you really need to send mail anonymously, and don't control the target mail server in this case, you could use an anonymous relay service, like the variety which come with many domain registrar's whois privacy products.
I was wondering what is the difference between sending a basic message and message using SMTP in cakephp
Regards
A basic message just uses PHP's mail function to drop off the message to whatever mail handler is configured locally. On your local computer this usually means that the machine will try to deliver the message itself, which often results in it either being rejected or going straight into the spam folder of the receiver. On a properly set up hosted server this is usually not a problem though.
Delivering via SMTP lets you specify an SMTP server that will take over the message delivery for you. A well known and established SMTP server has much better chances of delivering a message to the intended recipient.