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 937765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:31:51+00:00 2026-05-15T21:31:51+00:00

How can I send an HTML email using a shell script?

  • 0

How can I send an HTML email using a shell script?

  • 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-15T21:31:52+00:00Added an answer on May 15, 2026 at 9:31 pm

    First you need to compose the message. The bare minimum is composed of these two headers:

    MIME-Version: 1.0
    Content-Type: text/html
    

    … and the appropriate message body:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head><title></title>
    </head>
    <body>
    
    <p>Hello, world!</p>
    
    </body>
    </html>
    

    Once you have it, you can pass the appropriate information to the mail command:

    body = '...'
    
    echo $body | mail \
    -a "From: me@example.com" \
    -a "MIME-Version: 1.0" \
    -a "Content-Type: text/html" \
    -s "This is the subject" \
    you@example.com
    

    This is an oversimplified example, since you also need to take care of charsets, encodings, maximum line length… But this is basically the idea.

    Alternatively, you can write your script in Perl or PHP rather than plain shell.

    Update

    A shell script is basically a text file with Unix line endings that starts with a line called shebang that tells the shell what interpreter it must pass the file to, follow some commands in the language the interpreter understands and has execution permission (in Unix that’s a file attribute). E.g., let’s say you save the following as hello-world:

    #!/bin/sh
    
    echo Hello, world!
    

    Then you assign execution permission:

    chmod +x hello-world
    

    And you can finally run it:

    ./hello-world
    

    Whatever, this is kind of unrelated to the original question. You should get familiar with basic shell scripting before doing advanced tasks with it. Here you are a couple of links about bash, a popular shell:

    http://www.gnu.org/software/bash/manual/html_node/index.html

    http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html

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

Sidebar

Related Questions

How to send HTML content in email using Python? I can send simple texts.
How can I send an HTML-formatted email with pictures using PHP? I want to
I have several sites where users can send me email through an html form
I want to send the HTML email to new registered user. I am using
I am using MFMailComposeViewController class to send out formatted HTML email from my iPhone
How can i send an Email using PHP at windows Azure? i am using
We can send a mail using mailto: in HTML and JavaScript. Is there any
I'm trying to send an email message using the .NET MailMessage class which can
Possible Duplicate: Sending HTML email from PHP Using PHP to send an email. I
I'm using PEAR to send HTML emails from my website. My email are sent,

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.