Sending "on behalf of" emails - c#

I have been received a lot of emails "on behalf on". For example, the AddThis plugin sending a email from "addThis.com on behalf of myfriend#gmail.com".
How do I do this in C#/ASP.NET? Also, does this work if we use gmail for our SMTP, albeit branded to our company domain?
I'm also wondering if there are any concerns about this being unprofessional or getting flagged as spam on the client PC? In other words, have you guys actually implemented this...

You have three properties in the MailMessage class:
From
Sender
ReplyTo (or in .NET 4 the ReplyToList)
If you set the Sender different than the From, it should behave as you want it.
Please also see this SO posting for other aspects.

This is primarily a client app "feature". I'm guessing that you are viewing these email messages in Outlook, correct? Outlook (and possibly other email clients) compare the FROM address and the actual sender to see if they match. If they don't, Outlook will display the "On Behalf Of" information.
Most other email clients, and all web-based clients that I know of, simply display the "FROM" address as it was provided.

Related

Sending E-mail to localhost / "capturing" outgoing e-mail

I work with a dozen pieces of equipment whose operating software has the option to send e-mails on error. I would prefer to capture the details of that e-mail on the host PCs that run them (i.e. for logging, communicating details automatically via Slack, etc.) rather than them going to an inbox somewhere.
Is there a way to have the software e-mail an address that is essentially a lightweight piece of code running on the same PC mimicking something like an SMTP server (that will allow me to get after the message's contents)? Other solutions I have seen are along the lines of setting up a full-blown server which seems like overkill.
You may configure SmtpClient to save email to a specific folder instead of sending it over the wire. Check this answer.
Also you must design your system in the way it could work with different implementations of your 'sender', so that you can replace it when you need that, for example during testing. In this case you can easily provide proxy implementation that will capture email content and then send it to localhost, or add aspects (make retries, logs performance...).

Is there a way to forbid smtp transparent forwarding?

Problem steps :
My company sends mail to external partners (using .Net SmtpClient),
Some of them have set up "transparent forwarding" on our mails to some of their co-workers,
Those co-workers receive our mails as if we have send them directly to them (no "on behalf of", no classical "forward" from the original "To" mailbox), without any clue of which mail box has transparently forwarded them the mail.
(In fact, smtp conversation traces in the mail properties allows to find it, but most users are not tech savvy enough to be able to access such information, and we have not the knowledge for explaining them how to do for all the varieties of mail clients our partners may use),
Some of those co-workers complains to us that we are spamming them. And if their are unable to transmit us the offending mail untouched (usually as an attachment, preserving the smtp conversation traces), we are helpless in determining by which way they have got our mailing which was not originally directed to them.
Is there a way using SmtpClient to set-up some properties which forbids "transparent forwarding" ?
I do not want to forbid normal forwarding or copying as in How do I prevent Lotus Notes users from forwarding or copying a message sent via System.Net.Mail? question.
I just do want to forbid that "transparent forwarding" (which is IMHO a very bad feature of some mail systems like MS Exchange, which in its rules options gives two way of forwarding, one being "transparent").
As this feature looks to me as being not compliant to smtp RFC, I really fear the answer is no or almost no.
But if your are aware of some custom header for forbidding this on some of those mail systems who do offer that transparent forwarding feature, it may still be of some help to me if their are settable using SmtpClient.
If you are trying to solve the problem of not knowing who the original recipient of the message is, then try adding a line in the body of the message something like this...
"This message was intended for (insert recipient here)."
You can make it visible so the user can see who the original recipient was, or (if you can) put it in super small font so you can use it for troubleshooting/spam claim illustration purposes.

EMAIL from web server

We have a website sending mail alerts to end users. The site has been developed in c# ASP.NET.
I want to find the best way to send the email alerts to my users. Making sure the mail is not trapped in any spam filters. I read on the internet it is best to sent the mail directly from the web server and not route via an SMTP mail service such as google apps or Postini.
Can anyone tell me if this is correct?
First of all
Making sure the mail is not trapped in
any spam filters
Is not possible - otherwise spammers would do this. You just have to make sure you're domain isn't associated with any spamming activities and watch for keywords within the email.
I read on the internet it is best to
sent the mail directly from the web
server and not route via an SMTP mail
service such as google apps or
Postini.
This point doesn't make sense - your e-mail will never be delivered if it doesn't get routed via an SMTP server, the average message will pass through multiple on its route to the recipient.
The answer is to not actually send email and let someone else deal with the problem. I'd look at postmark or Amazon's simple email service.
We had problems that mails sent with local server often get trapped in spam filters until we implemented SPF on our mail server.
http://en.wikipedia.org/wiki/Sender_Policy_Framework
But I am not admin, that's just what our admin said, and after that we have no problems anymore.
btw. maybe would be better to ask on serverfault.com

How do I test my email settings without sending a message?

As part of my app's config process, I have a sanity checker that validates all user-supplied data. This includes email server settings that the app uses to send email.
I'd like a simple sanity check on those settings without actually sending any email. It'd be great if this could support all standard flavors of SMTP setups including those with authentication/ssl/etc.
It doesn't need to be exhaustive but the more coverage, the better.
Currently all I do is verify I can open a connection to the given server on the given port. Something a little deeper would be nice.
Note: I'm not trying to validate email addresses--that's not relevant to this question.
You just open a raw connection to the server & port that the user supplies and do a
HELO Server.Domain.Com
Mail From: validaccount#domain.com
to see if you get a valid HELO response & Sender OK Response
(if smtp authentication is enabled).
Same as you would do if you telnet direct to the server.
http://www.petri.co.il/test_smtp_service.htm
This might also be useful
http://qmail.jms1.net/test-auth.shtml
I'm sure someone brighter and more qualified will pipe up with a better answer. However, at first blush I'd say that you cannot verify the ability to successfully send email without actually sending an email.
However, if you want to automate the process, you can have a 'MyApp_SanityCheck#gmail.com' (or your local domain) address.
Then you can create a watchdog application that monitors that email address, or just a simple app which programmatically interfaces with that email address and checks if an email was received within X minutes. This way you can be 100% certain that the emails are able to be sent out.
This link shows how to programmatically check gmail addresses.
An important note: If you application is sending out external emails, then it would be best if the email address you use is external, because it is possible that your server could be unable to send external emails, but internal emails go through just fine, and in that case your sanity check would send up a false positive.

Programmatically Verify an email message reached an exchange mail box

I have a job that runs which sends out emails to our users to which starts off a work flow process in our company. Periodically, a user will swear up and down that they didn't receive the email - though, when we go to the mail administrator to pull an exchange report, 10 times out of 10 it's in their deleted items. :P
I'd like to be able to programmatically verify that messages sent via .net C# (System.Net.Mail I think) reached the user's mail box.
It's exchange 2007 and all messages are internal.
You can't with System.Net.Mail. You'll have to dig through Exchange's APIs to determine if an email is present in someone's email account.
http://support.microsoft.com/kb/813349
Set an account for catching all bounce backs. In this way you will know which ones reached and which ones did not. This is the best way to ensure emails reached.
Alternatively you can add read reciepts via message headers(by setting the Disposition-Notification-To). but again, user can chose not to read it...
I see two ways to do what you want:
Send emails with "delivery confirmation" On (not "read receipt", this can be dismissed by the user as CoddeToGlory said). Then it's jut a matter of monitoring the mailbox that receives these confirmations via any way it's appropiate to you: Exchange Web Services, Outlook+COM or VBA, MAPI, ...
Use the powershell interface to Exchange and capture the output of Get-MessageTrackingLog looking for StoreDriver + Deliver events.

Categories

Resources