0

I am using CodeIgniter for a school project. A part of the project requires an email to be sent towards someone. I got that part working (after a few hours xD).

But the last thing I need to do is style the email.

I got the following code:

$this->email->message('
    Beste '.$_POST['name'].' '.$_POST['lastname'].',

    Ten eerste heten wij u welkom bij BodyBook. Uw online medische dossier waarin u bepaalt wat er in staat. Privacy staat bij ons heel hoog en wij respecteren daarom ook de privacy van anderen.

    U Heeft zo juist een accoutn aangemaakt bij BodyBook.
    Hieronder staat uw voorlopig wachtwoord om mee in te loggen.
    Gelieve dit wachtwoord gelijk te veranderen op het moment dat uw voor het eerst inlogt.

    uw wachtwoord = 1234

    Wij wensen u veel plezier met BodyBook.

    Met Vriendelijk Groet,
    Het BodyBook team.
');

Yeah, the text is written in Dutch. :p Anyway, what I know want is that the following line:

uw wachtwoord = 1234

is bold and the font size is bigger the default. I searched the internet, but I don't understand how this works.

I already tried:

*uw wachtwoord = 1234*

But that didn't make it bold. I hope someone can help me.

Thanks in Advance,

Mark

DijkeMark
  • 1,284
  • 5
  • 19
  • 41
  • possible duplicate of [Sending HTML email from PHP](http://stackoverflow.com/questions/3058897/sending-html-email-from-php) – mario Dec 13 '11 at 13:35
  • You need to pass a mail header to your utility funtion somehow. Set it to MIME type `text/html` for using `bold` or even `text/richtext` to use `text...`. – mario Dec 13 '11 at 13:36
  • The asterisks makes the string bold in some mail programmes like Thunderbrid. You need the HTML way like socha23 said. – rekire Dec 13 '11 at 13:37

3 Answers3

3

You need to configure CodeIgniter to send HTML email: $config['mailtype'] = 'html';

Then you can mark bolded text by using <strong> tag, like this:

<strong>uw wachtwoord = 1234</strong>

One consequence of sending HTML email is it will mess up your formatting - in HTML multiple white spaces are ignored. You can create paragraphs by wrapping text in <p> </p> tags:

<p><strong>uw wachtwoord = 1234</strong></p>
<p>Wij wensen u veel plezier met BodyBook.</p>
socha23
  • 10,171
  • 2
  • 28
  • 25
  • Better use `` the `` tag is obsolete. – rekire Dec 13 '11 at 13:38
  • @rekire - indeed (although `` is so much more convenient). Updated my answer. – socha23 Dec 13 '11 at 13:42
  • @rekire: It ain't. That's a myth perpetrated by people who never used a text only browser or screen reader. XHTML is obsolete, not the `` tag. And if you want to make text bold, then `` will not reliably give the *desired* result. – mario Dec 13 '11 at 13:51
  • Thanks Socha23. That worked. You just saved my whole project. xD – DijkeMark Dec 13 '11 at 17:37
0

You can send messages as simple text or rich text which tends to be HTML. Simple text doesn't allow you to format text as you want. The user will read the message using it's email client defaults font and size no matter what you do. In case of HTML email, you can format with tons of things like pictures, font style, size, etc. Try the code from Socha23, for bold it should do the trick.

<b> text here </b>

for a larger font you could use CSS code. Try

<b style="font-size:24px">text here</b>

where 24px is the size of the font in pixels.

Bruno Faria
  • 5,219
  • 3
  • 24
  • 27
0

You can use TinyMCE which is platform independent web based HTML editor.

Vinay
  • 2,564
  • 4
  • 26
  • 35