Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Insert logo into email using php

Posted on 2015-01-19
7
Medium Priority
?
516 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 1002 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 498 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 1002 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
This video teaches users how to migrate an existing Wordpress website to a new domain.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

885 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