I am trying to send an email using c# MailMessage to a hotmail account but the emails are always going to junk.
How can i send emails directly to hotmail inbox in c#?
I don't have my own smtp server, therefore i have tried using my university开发者_开发知识库 smtp and other smtps like google, yahoo... but all emails were sent to junk.
Any solutions?
This is not really a C# question.
Mails are sent to spam depending on their content and their headers so you should check a few things :
- You need to have a subject
- you shouldn't have spammy words (sex, viagra, love, watches)
- You need to have a return-to and a from address headers that match
- You need to be consistent with your encoding, if you go for UTF8 send UTF8 text
- You shouldn't insert images
- Your links inside the mail, if any, should have their text set to the address they are going to
Using these strategies should help your email not being classified as spam.
You can always check the headers of one of the mail that went into spam. It is often described what rules were applied and where the mail failed.
In hotmail, open the Junk folder, click on the message. Hotmail will display options in the body of the message - click on "Wait, it's safe!" Hotmail will move the message to your inbox, and mark the FROM email address as safe.
There is (probably) nothing wrong with your code - it is hotmail identifying the sender and/or subject as being junk.
Although it may well be out of your control, junk email filters generally work on a weighting system, so there are things that you can do to make your email look less like spam.
To start with, check that:
- your subject doesn't contain all caps or sensitive words (such as "FREE!")
- your body has content
- the 'from' address for the MailMessage exists.
If those are all fine, have a look through this list, this article on live.com and the Policies, Practices and Guidelines for Hotmail.
What is the content of your mail, is it text that is likely to be regarded as junk mail by spam filters? Have you tried sending to other accounts such as Yahoo or Gmail?
You can't do it from C#. It is up to the recipient to route the messages to junk or inbox or wherever it decides to put the message. If the sender were allowed to decide where the message went on the client's side, imagine how much bigger of a problem spam would be.
One solution you can employ is to have your target mail account 'whitelist' the sender, but that may not be an option in all cases.
精彩评论