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

  • Home
  • SEARCH
  • 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 4623532
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:00:03+00:00 2026-05-22T03:00:03+00:00

So, I would like to use mail() to send registration emails for my website,

  • 0

So, I would like to use mail() to send registration emails for my website, however I’d like to make it look nice while falling back to good old plaintext when necessary; a mixed message email.

However I would like it to be sent from John Doe who’s email is johndoe@example.com to recipient@example.com.

The HTML code should be <html><head><title>HTML email!</title></head><body><p>This is HTML!</p></body</html> and the plaintext message should be This is plaintext.

What would be the arguments to mail() to accomplish this? I know a lot of it deals with changing the header in some crazy way.

Thanks so much!

  • 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-05-22T03:00:04+00:00Added an answer on May 22, 2026 at 3:00 am

    Use something like SwiftMailer instead, as it has nice things like header injection prevention. With that in mind, yes, you have to set custom headers and use a multi-part body to achieve what you want:

    /***************************************************************
     Creating Email: Headers, BODY
     1- HTML Email WIthout Attachment!! <<-------- H T M L ---------
     ***************************************************************/
    #---->Headers Part
    $Headers     =<<<AKAM
    From: $FromName <$FromEmail>
    Reply-To: $FromEmail
    MIME-Version: 1.0
    Content-Type: multipart/alternative;
        boundary="$boundary1"
    AKAM;
    
    #---->BODY Part
    $Body        =<<<AKAM
    MIME-Version: 1.0
    Content-Type: multipart/alternative;
        boundary="$boundary1"
    
    This is a multi-part message in MIME format.
    
    --$boundary1
    Content-Type: text/plain;
        charset="windows-1256"
    Content-Transfer-Encoding: quoted-printable
    
    $TextMessage
    --$boundary1
    Content-Type: text/html;
        charset="windows-1256"
    Content-Transfer-Encoding: quoted-printable
    
    $HTMLMessage
    
    --$boundary1--
    AKAM;
    

    Source: http://www.php.net/manual/en/function.mail.php#83491

    This is a lot of work. Which, once again, is why I recommend having a library that can handle all of this for you, plus other features.

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

Sidebar

Related Questions

The idea is before i send the mail , I would like to use
I do not want to use mail() to send e-mail. I would like to
I would like to use Exchange e-mail groups as an authentication scheme for an
I would like to use the Roboto font in my Android application and make
I would like to be able to send a string of emails at a
I would like to send mail from a script on a Windows Server 2003
internally, our organization limits what servers and applications can send emails. I would like
I would like my subversion to send me an e-mail (and my co-workers) on
I would like to use ListBox1.loadfromfile method in .NET, but it doesn't seem to
I would like to use a language that I am familiar with - Java,

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.