Confirm that mail successfully arrived - c#

i am used gmail to send mails from my asp.net page , but i want a method to Confirm ( make sure ) that the message successfully arrived to the recipients ( i add some recipients to BCC )
anybody can help me ??

there are two ways
request a read receipt
embed image to mail body
but as I know google doesn't support them. anyway search about those two ways.

I think you can not do this from your "send code" directly. I guess you need to use a some POP3 or IMAP api to see if there are a new email was recieved by recipient.
For example, you can only test if SMTP-server has accepted o rejected you message (spam-reason, auth error), but your cannot check if email was recieved by opponent
Or you maybe can use a "autoanswer" feature of you email client

With standard RFC822 email there's really no way to confirm receipt. To send a message, the mail client will talk to an SMTP server. The server may reject gross problems (ex. malformed email addresses). The server will attempt to forward the message to the destinations but somewhere along the way the message could fall on the floor. And of course the message could wind up in the destination mailbox but perhaps no one will read it.
Typically if delivery fails you'll eventually get a bounce message but this won't occur at the same time mail is delivered.

You have to use the some POP3 (protocol) library to check the recipient has received your email. POP3 is what you can use for retrieving mail, but it does not have support for PUSH either (so you would have to poll for mail).
The IMAP4 IDLE extension is what most refer to as PUSH mail - so you will need to find a library for C# that supports IMAP4 IDLE.
Check this link Using C# .Net Libraries to Check for Imap Messages
and also check this Accessing IMAP in C#
Keep in mind that your mail server also needs to have IMAP4 and IMAP4 IDLE enabled. Some mail servers don't support it, and will have to use POP3 polling.

Related

How to send Message Disposition Notification Email in node.js or C#/.NET?

I'm including a mail client in a software, and need to manage the "acknowledgment of receipt" sent with some e-mails.
Asking for one is simple, and implemented by the majority of librairies. What I'm searching is a way to (easily) generate an MDN mail in accordance to the standard defined here : https://www.rfc-editor.org/rfc/rfc3798#section-2.1, to reply to "read receipt" requests.
My software is in C#/.NET, and (for reasons) the e-mails are sent by a server in Node.js.
I could read and implement the standard by myself, but I don't want to reinvent the wheel, so I would like to know if a free library exists, in Node.js or in C#/.NET, allowing to automatically create an MDN mail. Alternatively, a good "How to" tutorial would be appreciated.
Thanks in advance for your help !
Edit :
I can't use the default behaviour of my mail server. I'm using my mailbox as a "buffer" : every mail I receive is processed and deleted from the mail server by my own custom server.
It is a bit tricky thing and depended from email server settings.
You could use cross-platform ImapClient:
http://www.imapx.org/
for extracting email notification from your email box in you application code . Your email server should support sending receive notification messages.
You can add custom data in header emails and extract it from notification body for distinguishing what exactly was pontificated.
for all types protocols you could use that (.Net):
https://www.emailarchitect.net/eagetmail/kb/csharp.aspx?cat=18
But the main idea remains the same - your system processes notification email from your email-box.

C# SMTP message transfer to recipient through MX Record

I know there many articles on web regarding sending emails from code/C# and I have read many of them before posting here, but I still don't see a clear picture of how to implement my requirements:
Scenario:
My application on mydomain.com receives a request to send some kind of email (from: someone#mydomain.com, to: someone#gmail.com/anyother.com).
I need to make some manipulations on email content.
After I modified a message, I need to send it directly to recipient.
Under directly to recipient I mean that I want to send it to recipient by our servers and not using some kind of SMTP service/relay.
So as I understand I can install some SMTP software on our servers and send using System.Net.Mail.SmtpClient to our server and it will deliver it to recipients using SMTP Relay or some other way that coded inside that software...but, I would like to make it without using SMTP Server software...
Till now I found that I need to discover MX record for recipients domain, so let's say I found MX record for gmail.com (gmail-smtp-in.l.google.com), but how do I send email to that MX Record from my own C# code?
Does System.Net.Mail.SmtpClient suitable for this task?
Where I can find examples of how to do it?
From my previous expirience with SmtpClient, I need to provide SMTP server address (optionaly port), credentials, but in my case, of course I do not have credentials and I'm not sure how to get the correct port (does all servers from MX records has port 25?).
Thanks!

How can i validate an email address and password is correct in asp.net?

I am trying to send emails using Yahoo or Gmail. Prior to that i want to check if the username and password combination of the email address i am using to send mails is ok and then send the email.
How can i achieve such a thing in Asp.net/C#?
Is there a way to find about the status of the sent email ? (delivered or failed?)
SmtpClient does not offer functions for testing credentials, e.g. just logging in without sending. So the .Net onboard way would be, as previously suggested, to Try/Catch your sending attempt.
If you insist on checking the credentials first, you'd have to implement the SMTP protocol, or parts of it, on your own, using .Net.Sockets.TcpClient. That way you could log on to the SMTP without sending anything.
It is possible to receive a so called NDR (Non-Delivery Report/Receipt), but since that is an email sent back to your designated bounce address, you would have to build an application to read those reports as a background process or similar. There is no guarantee that you will get an NDR.
I don't really see the point of checking username/password prior to sending. You would add error handling anyways, so it either fails or succeeds.

How do I prevent MS Exchange users from forwarding or copying a message sent via System.Net.Mail?

How do I prevent MS Exchange users from forwarding or copying a message sent via System.Net.Mail?
Not possible unless you write an Outlook plugin and even if you do, a determined user will always be able to do it one way or another.
You can't. If the email message was sent via Exchange rather than SMTP, you might be able to...with a server-side Exchange plugin/extension. But if the mail is sent via SMTP and is outside the Exchange server, you're SOL. The mail message is nothing more than a simple text file. Which see RFC 5322: Internet Message Format.
Further SMTP itself is a store-and-forward protocol. Every mail server involved in moving the message from sender to recipients gets a copy of the message and can keep it around.

Automatically creating email addresses and receiving emails with C#?

I'm a big fan of the email feature available in Backpack, where it creates a unique email address per backpack page, and any emails sent to that address will be posted to the page.
My question is about how best to go about creating new email addresses automatically, and listening for new emails sent to those addresses. I'd like to do this from a C# service (I'm not using ASP.Net)
Has anyone tried to achieve this or
something similar before?
Are there libraries (preferably
FLOSS) already available which do
this or would assist me?
Is it possible to do this using a cloud-based
email service (and if so, what service?) and a
library for communicating with that
service (OpenPop.Net or similar)?
If your email provider supports setting up wildcard email on your domain, then you can do this with a single email account.
For example, Google Apps for Domains allows setting *#example.com to be delivered to myaccount#example.com. When someone emails sales#example.com or contact#example.com it will all be delivered to myaccount#example.com.
Then it's a process of getting all the emails. You then look at the to header in the email, match that with the name stored in your application for that user, and then process however you wish.
Be aware that you will get spam and other incorrectly addressed emails when you use this method. You will have to deal with these yourself (eg by discarding incorrectly mail that isn't addressed to a valid account).
I haven't played around much with incoming mails, but from the top level here is what you should do.
Create email addresses for the users based on any logic and save it in the DB.
Setup a mail server with your domain name and set one email account as a "catch-all" mail account. Any mail sent to your domain would then be caught under that mail account, in case the email address is not found.
Create a windows service, that would read mails from that "Catch-All" account. There are several libraries available to read mails using POP3 or IMAP.
Read the incoming mails to check the email address it was sent to, compare it with the values stored in the DB and process accordingly.
Check this question. it might help you with reading incoming mails.
The objective isn't to create email addresses, that doesn't really happen. What you do is accept email addresses at your system, what you accept is up to you. You could set up a mail server to receive any email sent to your domain, you could then parse the email To field and extract the 'name' portion. If it matches something you are listening for then you action it accordingly.
I don't think you'll find a library for this specific activity as it's rather insular. There are plenty of ways of receiving emails directly or indirectly and processing them in C# but I won't cover that as mail handling in .Net is well documented.

Categories