Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Contact Us Form Security advice (Email)Contact Us Form Security advice (Email)
Previous
 
Next
New Post
7/18/2016 2:19 AM
 

Hello,

I have a simple Contact Us form module that sends an email that I am planning on implementing it on live, but i have been wondering what kind of security measures should I be paying attention to code wise or not.

                    mail.To = emailto.text;

                    mail.From = emailfrom.text;

                    mail.Subject = subject.text;

                    mail.Body = message.text;

                    mail.BodyFormat = System.Web.Mail.MailFormat.Html;

                    mail.BodyEncoding = Encoding.UTF8;

                    System.Web.Mail.SmtpMail.SmtpServer = "xxx.xxx.xxx.xxx";

                    System.Web.Mail.SmtpMail.Send(mail);

Note: Using dnn 7.2

 

Thanks,

 
New Post
7/18/2016 2:41 AM
 

Rashid,

Why not using an existing module like DNN Feedback?

Otherwise:

using DotNetNuke.Security;
[...]
mail.Body = PortalSecurity.InputFilter(message.Text, PortalSecurity.FilterFlag.MultiLine | PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting);
[...]

Find more information about input filtering here.

You should not use the System.Web.Mail.SmtpMail functions to deliver your mail. There is a SendMail function in the DotNetNuke.Services.Mail namespace that automatically takes the SMTP server and credentials from the host settings (or portal settings if defined). That would be more DNN-style. See here and here.

Happy DNNing!
Michael


Michael Tobisch
DNN★MVP

dnn-Connect.org - The most vibrant community around the DNN-platform
 
New Post
7/18/2016 6:54 AM
 
Dear Michael,

Thank you for your reply, the portalsecuriy.inputfilter is perfect didn't know about it before and I will use DotNetNuke.Services.Mail!

Thank you very much!

Regards,
 
New Post
7/19/2016 7:17 AM
 
Rashid,

I am glad I could help you.

Happy DNNing!
Michael

Michael Tobisch
DNN★MVP

dnn-Connect.org - The most vibrant community around the DNN-platform
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Contact Us Form Security advice (Email)Contact Us Form Security advice (Email)


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out