0

我正在使用 mailchimp 批量电子邮件订阅向我的客户发送时事通讯电子邮件。但是,有人正在使用某种机制来触发来自我网站的电子邮件。

我不断地从我的网站收到大量电子邮件。

有什么方法可以阻止这种黑客活动吗?

正因为如此,我的订阅很快就会关闭,因为我每分钟使用更多的电子邮件。

这是我的代码:

protected void btnSubmit_Click(object sender, EventArgs e)  
{  
        //Fetching Settings from WEB.CONFIG file.  
        string emailSender = ConfigurationManager.AppSettings["emailsender"].ToString();  
        string emailSenderPassword = ConfigurationManager.AppSettings["password"].ToString();  
        string emailSenderHost = ConfigurationManager.AppSettings["smtpserver"].ToString();  
        int emailSenderPort = Convert.ToInt16(ConfigurationManager.AppSettings["portnumber"]);  
        Boolean emailIsSSL = Convert.ToBoolean(ConfigurationManager.AppSettings["IsSSL"]);  


        //Fetching Email Body Text from EmailTemplate File.  
        string FilePath = "D:\\MBK\\SendEmailByEmailTemplate\\EmailTemplates\\SignUp.html";  
        StreamReader str = new StreamReader(FilePath);  
        string MailText = str.ReadToEnd();  
        str.Close();  

        //Repalce [newusername] = signup user name   
        MailText = MailText.Replace("[newusername]", txtUserName.Text.Trim());  


        string subject = "Welcome to CSharpCorner.Com";  

        //Base class for sending email  
        MailMessage _mailmsg = new MailMessage();  

        //Make TRUE because our body text is html  
        _mailmsg.IsBodyHtml = true;  

        //Set From Email ID  
        _mailmsg.From = new MailAddress(emailSender);  

        //Set To Email ID  
        _mailmsg.To.Add(txtUserName.Text.ToString());  

        //Set Subject  
        _mailmsg.Subject = subject;  

        //Set Body Text of Email   
        _mailmsg.Body = MailText;  


        //Now set your SMTP   
        SmtpClient _smtp = new SmtpClient();  

        //Set HOST server SMTP detail  
        _smtp.Host = emailSenderHost;  

        //Set PORT number of SMTP  
        _smtp.Port = emailSenderPort;  

        //Set SSL --> True / False  
        _smtp.EnableSsl = emailIsSSL;  

        //Set Sender UserEmailID, Password  
        NetworkCredential _network = new NetworkCredential(emailSender, emailSenderPassword);  
        _smtp.Credentials = _network;  

        //Send Method will send your MailMessage create above.  
        _smtp.Send(_mailmsg);  



    }  
} 
4

1 回答 1

1

您的表单上应该有验证码:https: //www.google.com/recaptcha/intro/v3.html

在您的网站上添加对 library/bin/Release/Recaptcha.dll 的引用:在 Visual Studio 网站菜单上,选择添加引用,然后单击对话框中的 .NET 选项卡。从 .NET 组件列表中选择 Recaptcha.dll 组件,然后单击确定。如果您没有看到该组件,请单击“浏览”选项卡并在硬盘驱动器上查找装配文件。通过添加以下代码片段将 reCAPTCHA 控件插入您希望保护的表单中: 在 aspx 页面的顶部,插入:

<%@ Register TagPrefix="recaptcha" Namespace="Recaptcha" Assembly="Recaptcha" %>

然后在标签内插入 reCAPTCHA 控件:

<recaptcha:RecaptchaControl
    ID="recaptcha"
    runat="server"
    PublicKey="your_public_key"
    PrivateKey="your_private_key"
    />

您需要将您的公钥和私钥分别替换为 PublicKey 和 PrivateKey。

确保您使用 ASP.NET 验证来验证您的表单(您应该在提交时检查 Page.IsValid)。

于 2018-11-19T11:15:32.933 回答