简体   繁体   English

垃圾邮件发送

[英]Mail sent in spam

I have made asp.net webservice in C# to send mail on given mailid as parameter. 我已经在C#中制作了asp.net网络服务,以给定的mailid作为参数发送邮件。

Mail is sent but it is shown as spam, not as an inbox mail. 邮件已发送,但显示为垃圾邮件,而不是收件箱邮件。

I have used following code; 我使用了以下代码;

.NET CODE : .NET代码:

public int SendMail(string mailto, string username, string password)
    {
        try
        {
            string mailFrom = "test@gmail.com";
            string siteName = "www.XYZ.com";
            MailAddress fromAddress = new MailAddress(mailFrom, siteName);
            SmtpClient mailClient = new SmtpClient();

            MailMessage message = new MailMessage();
            message.From = fromAddress;
            message.To.Add(mailto);

            message.Subject = "Your User Name and Password";
            message.IsBodyHtml = true;

            mailClient.Host = "relay-hosting.secureserver.net";
            mailClient.UseDefaultCredentials = false;
            mailClient.EnableSsl = false;

            string body = "<HTML><BODY><CENTER><H2>Your User Name  :'" + username + "' </H2><BR/><H2>Your Password :'" + password + "' </H2></CENTER></BODY></HTML>";

            message.Body = body;

            mailClient.Send(message);

            return 1;
        }
        catch (Exception ex)
        {
            return 0;
        }
    }

WEB.CONFIG CODE : WEB.CONFIG代码:

    <system.net>
    <mailSettings>
        <smtp from="test@gmail.com">
            <network host="relay-hosting.secureserver.net" />
        </smtp>
    </mailSettings>
  </system.net>

What can be the problem ? 可能是什么问题?

Thank you.. 谢谢..

The content of your MailMessage is being identified as spam by the recipient's provider or the relay server you're using is blacklisted. 收件人的提供者将MailMessage的内容标识为垃圾邮件,或者您正在使用的中继服务器被列入黑名单。 If you are using relay-hosting.secureserver.net the later is probably the case. 如果您正在使用relay-hosting.secureserver.net ,则可能是后者。 I would suggest using a more trusted relay provider than GoDaddy. 我建议使用比GoDaddy更受信任的中继提供程序。

Your FROM address is GMAIL.COM and you are NOT sending email from GMAIL server but from another server. 您的FROM地址是GMAIL.COM,您不是从GMAIL服务器发送电子邮件,而是从其他服务器发送电子邮件。 Using DomainKeys Identified Mail (DKIM) and Sender Policy Framework (SPF) it is now possible (and most sysadmins do) specify authorized email sending servers for that domain in the domain's DNS records. 现在,可以使用DomainKeys Identified Mail(DKIM)和发件人策略框架(SPF)(大多数系统管理员都可以)在域的DNS记录中为该域指定授权的电子邮件发送服务器。 This way, when a email recipient server receives an email, it can check for authenticity of the source of the email by checking the email sending server with the list of servers mentioned as authorized in the sender domain's DNS. 这样,当电子邮件收件人服务器接收到电子邮件时,它可以通过使用发件人域的DNS中提到的授权服务器列表检查电子邮件发送服务器,来检查电子邮件来源的真实性。 If it does not match, then as per rules set or specified by the sender domain's sysadmin in their DNS record, the email may be outright rejected or saved as spam in the spam folder. 如果不匹配,则按照发件人域的sysadmin在其DNS记录中设置或指定的规则,该电子邮件可能会被彻底拒绝或另存为垃圾邮件在垃圾邮件文件夹中。

I guess this is what is happening. 我想这就是正在发生的事情。 You should also check the sending server (SMTP) credentials using http://www.mxtoolbox.com/blacklists.aspx service before sending emails. 您还应该在发送电子邮件之前使用http://www.mxtoolbox.com/blacklists.aspx服务检查发送服务器(SMTP)凭据。

The email will likely show up as spam if you send from an IP address that does not have a valid SPF record for the domain you are claiming it is coming from. 如果您从IP地址发送的电子邮件中没有该SPF记录的有效域名,则该电子邮件可能会显示为垃圾邮件。 In this example ""relay-hosting.secureserver.net" does not have a valid IP address to act as an SMTP server for gmail. 在此示例中,““ relay-hosting.secureserver.net”没有有效的IP地址用作Gmail的SMTP服务器。

Try doing a test sending from the actual domain you will be using in real life instead of "test@gmail.com". 尝试从实际使用的实际域(而不是“ test@gmail.com”)发送测试。

If it still gets marked as spam it is very easy to add an SPF record for test@ youractualdomain.com . 如果仍然被标记为垃圾邮件,则很容易为test @ youractualdomain.com添加SPF记录。 Here is a site that has helped me in the past: http://www.zytrax.com/books/dns/ch9/spf.html 这是过去对我有帮助的网站: http : //www.zytrax.com/books/dns/ch9/spf.html

There are several things at play that conspire to raise the spam score of your email. 有几件事可以共同提高电子邮件的垃圾邮件分数。 Remember that it's not spam/notspam, but rather a "spam score" above which your email will be marked as spam by the receiving server. 请记住,它不是垃圾邮件/不是垃圾邮件,而是“垃圾邮件分数”,高于该分数邮件将被接收服务器标记为垃圾邮件。

I would guess that the factors at play in your case are the folowing: 我想您的情况正在发挥以下作用:

  • HTML body with no alternative text message 没有替代文本消息的HTML正文
  • From address does not correspond to actual server mail is sent from 发件人地址与实际发送的服务器邮件不符
  • From address does not exist 发件人地址不存在
  • SMTP server (relay-hosting.secureserver.net) has a low reputation SMTP服务器(relay-hosting.secureserver.net)信誉低
  • No SPF or domainKey records 没有SPF或domainKey记录

The solution is in several points as well: 该解决方案也有以下几点:

  • Create an alternate text version of your message and include it in the body ( this answer explains how to do that) 创建邮件的备用文本版本并将其包含在正文中( 此答案说明了如何执行此操作)
  • Use a From address that actually exists on the server the email is sent from 使用发送电子邮件的服务器上实际存在的发件人地址
  • Use a reputable provider for your SMTP server, such as Sendgrid , postmarkApp or Mailjet 使用一个有信誉的供应商为您的SMTP服务器,如SendgridpostmarkAppMailjet
  • Specifying SPF and DomainKeys DNS records allows the receiving server to identify your message as coming from the right server 指定SPF和DomainKeys DNS记录使接收服务器可以将您的邮件标识为来自正确的服务器

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM