1

Is it possible to format the string within a variable within PHP script.

The following script sends an email to the user. The part shown is my entire body of the email including my signature. I want to bold or change the font size of my signature and everything I've tried didn't work.

I tried including within the string, but it just reads the code and not implementing it. Tried to look over all the web to see if there's a possibility, but all the results show echo......

<?php 
    if(isset($_POST['button_1'])){
        $to = $_POST['email'];
        $from = 'xxxxx <xxxx@xxxxx.edu>';
        $subject = "Thank you for your interest";
        $message ="Name" . "\n" . "Work" . "\n" . "Position" . 
                    "\n" . "(xxx) xxx-xxxx" . "\n" . "xxxx@xxxx.edu";
        $headers="From:" . $from; mail($to, $subject, $message, headers);
        mail($to,$subject,$message,$headers); 
    }
?>

Trying to format "Name" within $message

Bluetree
  • 1,324
  • 2
  • 8
  • 25
  • 1
    Possible duplicate of [Send HTML in email via PHP?](https://stackoverflow.com/questions/11238953/send-html-in-email-via-php) – Adam Oct 31 '17 at 19:56

1 Answers1

1

You should use html in your text body. For example, to make text to be bold you should use:

$message = "<b>Your text here</b>";

To enable html in your message your should set these headers:

$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
Dmitriy Buteiko
  • 624
  • 1
  • 6
  • 14