• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

How to echo mail() to show no html tags inside the recieved email body

I have a mail() script that emails customers with user information. Is there a way to strip out all of the HTML tags from the body of the email? Here is an example:

Original Email:
-------------------------------------------------------------------------------------------------------------------
This email message is to confirm your purchase of product(s) from RandomSite.com.<br />
<br />
Pimp Vector Collection<br />
Item Quantity: 1<br />
Item Price: $0.35USD<br />
Activation Code: EE5E-FEE2-BD78-FC3A<br />
<br />
<br />
<br />
If you do not already have an account at our store, please create a new account. Once your new account has been created, you will be able to activate and download your purchased product(s).<br />
<br />
Regards,<br />
RandomSite.com Team<br />
http://www.RandomSite.com
-------------------------------------------------------------------------------------------------------------------

Desired Email:
-------------------------------------------------------------------------------------------------------------------
This email message is to confirm your purchase of product(s) from RandomSite.com.

Pimp Vector Collection
Item Quantity: 1
Item Price: $1.00USD
Activation Code: EE5E-FEE2-BD78-FC3A


If you do not already have an account at our store, please create a new account. Once your new account has been created, you will be able to activate and download your purchased product(s).

Regards,
RandomSite.com Team
http://www.RandomSite.com
-------------------------------------------------------------------------------------------------------------------

Attached is the file I think I need to edit. Thanks!
class-mailer.php
0
efrainanegron
Asked:
efrainanegron
  • 3
  • 2
2 Solutions
 
aboo_sCommented:
0
 
efrainanegronAuthor Commented:
Hm, I'm not quite sure how to implement that while using the nl2br() function. Any idea how?
0
 
Avinash ZalaWeb ExpertCommented:
In  your attached file use strip_tags instead of nl2br

Hope this helps.
Addy
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
aboo_sCommented:
Here you go:

function sendMail($to, $subject, $body)
      {
          $from = "From: " . $this->sitemail . " <" . $this->sitename . ">";
              $headers = "MIME-Version: 1.0" . "\r\n";
              $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
              $headers .= "From: <" . $this->sitemail . "> " . $this->sitename . "" . "\r\n";
              $body = nl2br($body);
                  $body = strip_tags($body, '<br><br/><a>');
            
          return mail($to, $subject, $body);
      }
*-
0
 
efrainanegronAuthor Commented:
The results were great! Thanks!
0
 
efrainanegronAuthor Commented:
Thanks guys!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now