Solved

Insert logo into email using php

Posted on 2015-01-19
7
412 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
  • 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 30

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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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 30

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now