• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 551
  • Last Modified:

Insert logo into email using php

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
Scott Johnston
Asked:
Scott Johnston
  • 3
  • 2
  • 2
3 Solutions
 
Jason C. LevineNo oneCommented:
$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
 
Marco GasiFreelancerCommented:
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
 
Scott JohnstonSystems ConsultantAuthor Commented:
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
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
Scott JohnstonSystems ConsultantAuthor Commented:
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
 
Jason C. LevineNo oneCommented:
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
 
Scott JohnstonSystems ConsultantAuthor Commented:
I was just confirming. THANK YOU!!!!
I am now going on a new adventure and learning something new!
Thank you very much.....
0
 
Marco GasiFreelancerCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now