Solved

Insert logo into email using php

Posted on 2015-01-19
7
480 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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 

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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

623 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