Solved

Insert logo into email using php

Posted on 2015-01-19
7
468 Views
Last Modified: 2015-01-20
We have some coding that generates a email for our customers.
This generates the email but I like to insert a Company logo into the email.
I tired to add a line to the Message:

""img src="http://www.biotone.com/images/logo.png".

but it will not work correctly....any type of advice will be appreciated!!!

$message = "";
                if(isset($_SESSION["NewAccountCreated"])) {
                    $message = "Hello ".$order->Billing->Name.",\n".
                        "Thank you for ordering and registering an account at www.biotone.com. ".
                        "We have received your order. Should you need to make changes to your order, ".
                        "please call us at 800.445.6457, during our normal business hours (see below). ".
                        "We are glad to help you. Please remember, orders placed by 12 noon, pacific time, ".
                        "ship the same business day. Below is your order confirmation number, please ".
                        "keep a copy of it should you need to reference your order.\n\n".
                        "Order Confirmation #: ".$salesOrderNumber."\n\n".
                        "Account #: ".$account->CustomerNumber."\n\n".
                        "Thank you!\n-The BIOTONE Team";
                } //end if
                else if(isset($_SESSION["LoginEmail"])) {
                    $message = "Order Acknowledged\n\n".
                        "Thank you for your recent order. ".
                        "Whats Next? Once your order ships an Invoice and tracking number ".
                        "will be emailed to you.  ".
                        "Should you need to make changes to your ".
                        "order, please call us at 800.445.6457.\n\n".
                        "\t\t\t Order Confirmation #: \t\t".$salesOrderNumber."\n".
                        "\t\t\t Account #: \t\t\t".$account->CustomerNumber."\n\n".
                        "Customer Name  \t".$order->Billing->Name.".\n".
                        "Address        \t\t".$order->Billing->Address1.".\n".
                        "City  \t\t\t".$order->Billing->City.".\n".
                        "State \t\t\t".$order->Billing->State.".\n".
                        "Order Total \t\t $ ".$order->Total.".\n".
            ""img src="http://www.biotone.com/images/logo.png".
                        "\n";
                } //end else

                //developers email should go here if on the test server

                /**
                 * 4-14-2011
                 * If the email address is missing (somehow) then send the email to
                 * the backup email. On the development server, send to developer's email.
                 */

                $mail = new Email("Order has been confirmed",$email);
                $mail->Message = $message; //set the email content
                $mail->From = $csemail; //set the reply-to
                $mail->ReturnTo = $csemail;
                $mail->setPlainHeaders(); //set the headers to plain text
                $mail->RecordRequest = true; //record into SQL table for easier access
                if($_SERVER['REMOTE_ADDR'] == Tools::$Biotone) {
                    $mail->RecordRequest = false;
0
Comment
Question by:Scott Johnston
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 70

Assisted Solution

by:Jason C. Levine
Jason C. Levine earned 334 total points
ID: 40558470
$mail->setPlainHeaders(); //set the headers to plain text

You're creating a plain text email.  No HTML tags will work.  In order to make the logo show up, you need to create an HTML or multipart MIME email and then add the appropriate tags to everything.
0
 
LVL 31

Assisted Solution

by:Marco Gasi
Marco Gasi earned 166 total points
ID: 40558485
First, the image must be a html tag

   "<img src='http://www.biotone.com/images/logo.png' />".

Second you are using too mutch double quotes without escaping them: use as I did above doube quotes and single quotes or escape the quotes must be treated as text

   "<img src=\"http://www.biotone.com/images/logo.png\" />".

Third, you have to be sure your plugin can send html emails.

Fourth, I don't think the result will be too well formatted if you just insert an image at the end without preparing a full html markup for your email. You can find a working example here: http://java.dzone.com/articles/responsive-html-email-template?mz=46483-html5.

hth
Marco

instead of "img...
0
 

Author Comment

by:Scott Johnston
ID: 40558610
Guys, is there a proper way to send a email in HTML format...
can I change this line of coding...
                             $mail->setPlainHeaders(); //set the headers to plain text

?
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 

Author Comment

by:Scott Johnston
ID: 40558621
I change the $mail->setPlainHeaders(); //set the headers to plain text
to
$mail->setHTMLHeaders(); //set the headers to plain text
it reformatted my wemail, which is fine, but now I think I' going to have to change out the Plain text coding and used HTML tags?

?
0
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 334 total points
ID: 40558646
it reformatted my wemail, which is fine, but now I think I' going to have to change out the Plain text coding and used HTML tags?

Correct. See above where I say:

" In order to make the logo show up, you need to create an HTML or multipart MIME email and then add the appropriate tags to everything."
0
 

Author Comment

by:Scott Johnston
ID: 40558665
I was just confirming. THANK YOU!!!!
I am now going on a new adventure and learning something new!
Thank you very much.....
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 40560911
skcbd, can you explain the B grade? I think you have got three explicative answers to your question and I really don't understand the reason of the downgrade...
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
This article discusses how to implement server side field validation and display customized error messages to the client.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn how to count occurrences of each item in an array.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question