0

I want to take input parameters from user and then use that in sentences in mail body,then i want some words(this will be user input) in the sentences to be bold.So when i send that mail to gmail/outlook those words should appear in bold

import smtplib
BOLD='\033[1m'
END='\033[1;m'
sender ='username@domain.com'
receiver=['username@domain.com']

title=raw_input("enter title:")
subject="Test"

body="HI All\n\nThe title entered is:{0} {1} {2}".format(BOLD,title,END)

message="Subject:{0}\n\n{1}".format(subject,body)

try:
  smtpobj=smtplib.SMTP('localhost')
  smtpObj.sendmail(sender,receivers,message)
  print "Mail sent"
except SMTPException:
  print "Error: Failed to send"

Now after doing this, when you open outlook and check mail, i want that title(must be user input) to be in bold,but it prints the BOLD code in the mail body rather than printing that title in bold

Note- the variable that we need to make bold should be input from user i.e it will be dynamic and not hardcoded..so i guess we can't do using html

Sven Eberth
  • 3,057
  • 12
  • 24
  • 29

1 Answers1

0

Your email is sent as plain text, which you cannot make bold. If you want to change your plain text to HTML you can easily make it bold.

A similar question was asked here.

You might also look at this question, where they use your library to send HTML.

JANO
  • 2,995
  • 2
  • 14
  • 29