Prevent email triggering from external source in ASP.Net Web Forms











up vote
0
down vote

favorite












I'm using mailchimp bulk email subscription to send newsletter email to my customers. But, someone is using some mechanism to trigger emails from my website.



I'm getting bulk emails continuously one after another from my website.



Is there any way available to stop this hacking activity?



Becuase of this, my subscription is closing very soon as I'm using more emails per minute.



Here's my code:



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);



}
}









share|improve this question


























    up vote
    0
    down vote

    favorite












    I'm using mailchimp bulk email subscription to send newsletter email to my customers. But, someone is using some mechanism to trigger emails from my website.



    I'm getting bulk emails continuously one after another from my website.



    Is there any way available to stop this hacking activity?



    Becuase of this, my subscription is closing very soon as I'm using more emails per minute.



    Here's my code:



    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);



    }
    }









    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm using mailchimp bulk email subscription to send newsletter email to my customers. But, someone is using some mechanism to trigger emails from my website.



      I'm getting bulk emails continuously one after another from my website.



      Is there any way available to stop this hacking activity?



      Becuase of this, my subscription is closing very soon as I'm using more emails per minute.



      Here's my code:



      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);



      }
      }









      share|improve this question













      I'm using mailchimp bulk email subscription to send newsletter email to my customers. But, someone is using some mechanism to trigger emails from my website.



      I'm getting bulk emails continuously one after another from my website.



      Is there any way available to stop this hacking activity?



      Becuase of this, my subscription is closing very soon as I'm using more emails per minute.



      Here's my code:



      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);



      }
      }






      asp.net email smtp mailchimp bulk-email






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 6 hours ago









      55SK55

      469




      469
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          You should have captcha on your form: https://www.google.com/recaptcha/intro/v3.html



          Add a reference on your website to library/bin/Release/Recaptcha.dll: On the Visual Studio Website menu, choose Add Reference and then click the .NET tab in the dialog box. Select the Recaptcha.dll component from the list of .NET components and then click OK. If you don't see the component, click the Browse tab and look for the assembly file on your hard drive.
          Insert the reCAPTCHA control into the form you wish to protect by adding the following code snippets:
          At the top of the aspx page, insert this:



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


          Then insert the reCAPTCHA control inside of the tag:



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


          You will need to substitute your public and private key into PublicKey and PrivateKey respectively.



          Make sure you use ASP.NET validation to validate your form (you should check Page.IsValid on submission).






          share|improve this answer








          New contributor




          Sergiu Muresan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.


















          • Is there any other options available?
            – 55SK55
            4 hours ago










          • You need to block the bots from submitting the form and by using captcha you can do this. From my experience Google ReCaptcha is the best option. There are other options as well: codeproject.com/articles/773785/…
            – Sergiu Muresan
            2 hours ago











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371327%2fprevent-email-triggering-from-external-source-in-asp-net-web-forms%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote













          You should have captcha on your form: https://www.google.com/recaptcha/intro/v3.html



          Add a reference on your website to library/bin/Release/Recaptcha.dll: On the Visual Studio Website menu, choose Add Reference and then click the .NET tab in the dialog box. Select the Recaptcha.dll component from the list of .NET components and then click OK. If you don't see the component, click the Browse tab and look for the assembly file on your hard drive.
          Insert the reCAPTCHA control into the form you wish to protect by adding the following code snippets:
          At the top of the aspx page, insert this:



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


          Then insert the reCAPTCHA control inside of the tag:



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


          You will need to substitute your public and private key into PublicKey and PrivateKey respectively.



          Make sure you use ASP.NET validation to validate your form (you should check Page.IsValid on submission).






          share|improve this answer








          New contributor




          Sergiu Muresan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.


















          • Is there any other options available?
            – 55SK55
            4 hours ago










          • You need to block the bots from submitting the form and by using captcha you can do this. From my experience Google ReCaptcha is the best option. There are other options as well: codeproject.com/articles/773785/…
            – Sergiu Muresan
            2 hours ago















          up vote
          1
          down vote













          You should have captcha on your form: https://www.google.com/recaptcha/intro/v3.html



          Add a reference on your website to library/bin/Release/Recaptcha.dll: On the Visual Studio Website menu, choose Add Reference and then click the .NET tab in the dialog box. Select the Recaptcha.dll component from the list of .NET components and then click OK. If you don't see the component, click the Browse tab and look for the assembly file on your hard drive.
          Insert the reCAPTCHA control into the form you wish to protect by adding the following code snippets:
          At the top of the aspx page, insert this:



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


          Then insert the reCAPTCHA control inside of the tag:



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


          You will need to substitute your public and private key into PublicKey and PrivateKey respectively.



          Make sure you use ASP.NET validation to validate your form (you should check Page.IsValid on submission).






          share|improve this answer








          New contributor




          Sergiu Muresan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.


















          • Is there any other options available?
            – 55SK55
            4 hours ago










          • You need to block the bots from submitting the form and by using captcha you can do this. From my experience Google ReCaptcha is the best option. There are other options as well: codeproject.com/articles/773785/…
            – Sergiu Muresan
            2 hours ago













          up vote
          1
          down vote










          up vote
          1
          down vote









          You should have captcha on your form: https://www.google.com/recaptcha/intro/v3.html



          Add a reference on your website to library/bin/Release/Recaptcha.dll: On the Visual Studio Website menu, choose Add Reference and then click the .NET tab in the dialog box. Select the Recaptcha.dll component from the list of .NET components and then click OK. If you don't see the component, click the Browse tab and look for the assembly file on your hard drive.
          Insert the reCAPTCHA control into the form you wish to protect by adding the following code snippets:
          At the top of the aspx page, insert this:



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


          Then insert the reCAPTCHA control inside of the tag:



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


          You will need to substitute your public and private key into PublicKey and PrivateKey respectively.



          Make sure you use ASP.NET validation to validate your form (you should check Page.IsValid on submission).






          share|improve this answer








          New contributor




          Sergiu Muresan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          You should have captcha on your form: https://www.google.com/recaptcha/intro/v3.html



          Add a reference on your website to library/bin/Release/Recaptcha.dll: On the Visual Studio Website menu, choose Add Reference and then click the .NET tab in the dialog box. Select the Recaptcha.dll component from the list of .NET components and then click OK. If you don't see the component, click the Browse tab and look for the assembly file on your hard drive.
          Insert the reCAPTCHA control into the form you wish to protect by adding the following code snippets:
          At the top of the aspx page, insert this:



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


          Then insert the reCAPTCHA control inside of the tag:



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


          You will need to substitute your public and private key into PublicKey and PrivateKey respectively.



          Make sure you use ASP.NET validation to validate your form (you should check Page.IsValid on submission).







          share|improve this answer








          New contributor




          Sergiu Muresan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          share|improve this answer



          share|improve this answer






          New contributor




          Sergiu Muresan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          answered 4 hours ago









          Sergiu Muresan

          1046




          1046




          New contributor




          Sergiu Muresan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.





          New contributor





          Sergiu Muresan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          Sergiu Muresan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.












          • Is there any other options available?
            – 55SK55
            4 hours ago










          • You need to block the bots from submitting the form and by using captcha you can do this. From my experience Google ReCaptcha is the best option. There are other options as well: codeproject.com/articles/773785/…
            – Sergiu Muresan
            2 hours ago


















          • Is there any other options available?
            – 55SK55
            4 hours ago










          • You need to block the bots from submitting the form and by using captcha you can do this. From my experience Google ReCaptcha is the best option. There are other options as well: codeproject.com/articles/773785/…
            – Sergiu Muresan
            2 hours ago
















          Is there any other options available?
          – 55SK55
          4 hours ago




          Is there any other options available?
          – 55SK55
          4 hours ago












          You need to block the bots from submitting the form and by using captcha you can do this. From my experience Google ReCaptcha is the best option. There are other options as well: codeproject.com/articles/773785/…
          – Sergiu Muresan
          2 hours ago




          You need to block the bots from submitting the form and by using captcha you can do this. From my experience Google ReCaptcha is the best option. There are other options as well: codeproject.com/articles/773785/…
          – Sergiu Muresan
          2 hours ago


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371327%2fprevent-email-triggering-from-external-source-in-asp-net-web-forms%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          'app-layout' is not a known element: how to share Component with different Modules

          android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

          SQL update select statement