Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8266257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:05:31+00:00 2026-06-08T05:05:31+00:00

I implemented a html email inside a html file. And i have a php

  • 0

I implemented a html email inside a html file. And i have a php file which uses the PHPMailer class to send emails.
What i want to achieve is, i have some text inside the html that should change depends who i send the email.

This is the php file that sends the emails

<?php
    // get variables
    $contact_name = addslashes($_GET['contact_name']);
    $contact_phone = addslashes($_GET['contact_phone']);
    $contact_email = addslashes($_GET['contact_email']);
    $contact_message = addslashes($_GET['contact_message']);

    // send mail
    require("class.phpmailer.php");
    $mailer = new PHPMailer();
    $mailer->IsSMTP();
    $mailer->Host = 'ssl://smtp.gmail.com:465';
    $mailer->SMTPAuth = TRUE;
    $mailer->Username = 'danyel.p@gmail.com';
    $mailer->Password = 'mypass';
    $mailer->From = 'contact_email';
    $mailer->FromName = 'PS Contact';
    $mailer->Subject = $contact_name;
    $mailer->AddAddress('pdaniel@gmail.com');
    $mailer->Body = $contact_message;
    if($mailer->Send())
        echo 'ok';
?>

And the html file containing a simple html mail implemented with tables and all that standard it need.

I want to ask braver minds than mine which is the best approach to accomplish this. 🙂

Thank you in advance,
Daniel!

EDIT: right now, in the $mailer->Body i have the $contact_message variable as a text email.. but i want in that body to load an html file containing an html email and i want to somehow change the body of the html email with the text inside this $contact_message variable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T05:05:35+00:00Added an answer on June 8, 2026 at 5:05 am

    One simple way to go is to have special tokens in your html files that will be replaced by the caller. For example assuming that you have two variables that might dynamically change content, name, surname then put something like this in your html: %%NAME%%, %%SURNAME%% and then in the calling script simply:

    $html = str_replace("%%NAME%%", $name, $html);
    $html = str_replace("%%SURNAME%%", $surname, $html);
    

    or by nesting the two above:

    $html = str_replace("%%NAME%%", $name, str_replace("%%SURNAME%%", $surname, $html));
    

    EDIT
    A more elegant solution in case you have many variables: Define an associative array that will hold your needles and replacements for them:

    $myReplacements = array ( "%%NAME%%"    => $name,
                              "%%SURNAME%%" => $surname
    );
    

    and use a loop to make it happen:

    foreach ($myReplacements as $needle => $replacement)
       $html = str_replace($needle, $replacement, $html);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Have application is implemented in JSP, HTML, JS, CSS and now i want
I am sending html emails through php . the email has a background image
I have implemented Facebook Connect into a HTML page exactly as the tutorial explains
I would like to send an HTML email with link on it that would
I'm using the Tapestry5 tapx template library to send an html email, as per
I want to send an email ussing an EJB but i the only thing
I have a web app which displays a list of emails that need to
After user places an order I have to send detailed email message containing order
I have read a good bit on the limitations of sending html email from
I've implemented authentication through WS-Security on my webservice as described at http://static.springframework.org/spring-ws/sites/1.5/reference/html/security.html , like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.