-2

I have this as my action='action.php' for a form and so after submitting the following will be emailed to the specific email as directed and within the email will be the info entered such as name but how can I edit the text showed in email?

I have this in my action.php

public function postContact() {

    $fullname = $_POST['fullname'];
    $email = $_POST['email'];

    $email_message = '
        Full Name: '.$fullname.'
        Email: '.$email.'
    ';

    mail('abc@abc.com', 'Subject', $email_message);

    return Redirect::to('thanks');
}

so when people submit I will get something like

Full Name: Full Name
Email: Email

I tried setting a tag and other tags into the variable but in the email I will just see the tag too.

Am I doing it wrong or this isn't even the way of doing it?

Dora
  • 6,776
  • 14
  • 51
  • 99
  • the question is a bit too unclear.please consider revising. – rjv Jan 17 '14 at 04:53
  • ah..Thanks let me try those, because I'm thinking of putting html tag into the mail function so I kept on searching things like html tag in php mail function that's why I never found the duplicate really sorry for my bad wording – Dora Jan 17 '14 at 04:57

2 Answers2

1

you need to set the content type in the header

add something like the following

$header = "Content-type:text/html;charset=iso-8859-1" . "\r\n";

mail('abc@abc.com', 'Subject', $email_message, $header);
CumminUp07
  • 119
  • 1
  • 8
0

Take a look on the mail() function in php manual, which describe you clearly that how to use HTML in your mail's message body.

OR More better solution is use one of them phpmailer or swiftmailer for mailing functionalists.

http://php.net/manual/en/function.mail.php#example-3383

jogesh_pi
  • 9,762
  • 4
  • 37
  • 65