Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8485525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:40:31+00:00 2026-06-10T20:40:31+00:00

Question is simple: should i use any type of sanitization when using PHPmailer class?

  • 0

Question is simple: should i use any type of sanitization when using PHPmailer class?

I made simple send mail form that use phpmailer class to send email. Curently i use only “htmlspecialchars” for sanitization (aldough i read that there is no need for this, but this information is not 100% reliable).

I tried to send some js code between tags, and i received it sanitized, but i am unsure if some oher type of attack can be done.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:40:33+00:00Added an answer on June 10, 2026 at 8:40 pm

    You are not required to sanitize anything before sending to phpMailer except checking if the email address entered is valid email address or not.

    Data sanitization are for 2 reasons : SQL injection and XSS or CSRF (Xross Site Scripting or Cross site Request Forgery)
    In either of cases, user has to see something as output based on their input.

    However, it is good that you asked about sanitization for mail classes because, ideally no one will ask for it. HTML tags? Ofcourse you can send HTML tags! You can define content-type as text/html

    What you need to sanitize?

    1. Attachment type! Irrespective of mail-client exploit is always found in attachments. Allow only following mime-types:

      image/jpeg’, ‘image/pjpeg’, ‘image/gif’, ‘image/png’, ‘application/msword’, ‘application/vnd.ms-office’, ‘application/vnd.openxmlformats-officedocument.wordprocessingml.document’, ‘application/vnd.openxmlformats-officedocument.wordprocessingml.template’, ‘application/vnd.openxmlformats-officedocument.spreadsheetml.sheet’, ‘application/vnd.openxmlformats-officedocument.presentationml.presentation’,’application/pdf’

    Checking for Extentions of the file is NOT recommended! Because, the mail client might use functions like get_file_contents() which will just open the file in browser and if it is javascript embedded with an extension of JPEG, it will STILL execute! (in IE6/IE7 it did) however, that again is browsers job to have powerful parsing mechanism. Content-Sniffing

    1. Size of attachments

    Make sure you have size limit.

    Exploit may or may not be in the mail, mail client has to take care of it. However, as a mailer-end coder, these are 2 things which you should take care of.

    Hope that helps 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question is really simple. When should I use List, IEnumerable and ArrayList. Here's
I have a dead-simple question. How to use any SQLite library with nodejs under
A recent talk about unordered_map in C++ made me realize that I should use
This is (should be) a simple question. I'd like to create a component like
This should be a fairly simple question to answer, but I am interested to
Should be a simple question for SDL experts. I am confused about the following
This should be a simple question, but I just can't recall the relevant API.
This should be a simple question, but I can't get it to work :(
This should be a simple question, but I just can't seem to figure it
This should be very simple question. There are many programming languages out there, compiled

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.