Home arrow PHP arrow Page 5 - Email Management Details

Exam Prep Questions - PHP

In this second part of a two-part article, you'll learn how to manage email headers when creating a PHP email program, attach a file to a message, and more. This article is excerpted from chapter eight of the Zend PHP Certification Study Guide, written by Zend Technlogies (Sams; ISBN: 0672327090).

  1. Email Management Details
  2. Attaching a File to a Message
  3. Attached Images for HTML Emails
  4. A Word About Email Delivery
  5. Exam Prep Questions
By: Sams Publishing
Rating: starstarstarstarstar / 8
November 16, 2006

print this article



  1. Your company sells a shopping cart written in PHP. Matching common industry practice, the shopping cart sends a confirmational email to the user after he has checked out.

    Your team has just ported the shopping cart from PHP on Gentoo Linux to PHP running on Windows Server 2003. They've correctly set the SMTP, smtp_port, and sendmail_from settings in php.ini, but this error appears when the shopping cart tries to send the confirmation email:

    Could not execute mail delivery program

    This is your team's first project using Windows Server, and everyone's a bit confused as to why this error is happening. The php.ini settings work fine on Linux, so what could be the problem?

    Choose from one of the following: 

    A.  The smtpserver service hasn't been started.

    B.  sendmail_path in php.ini needs to be commented out.

    C.  Microsoft Exchange needs configuring to accept email from PHP.

    D.  PHP cannot send email when running on Windows.

    The correct answer is B.

  2. Flush with the success of the shopping cart on Windows Server 2003, your company has decided that it would be a good idea to add Solaris to the list of supported operating systems. Because the shopping cart is already proven to work on Linux, it should be no trouble at all to get the cart working on Solaris.

    Your team goes out and buys a new Sun server. As Solaris doesn't come with PHP, you have to compile PHP by hand. At the same time, your network administrator decides to un-install the Solaris version of sendmail and replace it with the company's standard MTA—postfix—instead. He forgets to tell you that he's done this.

    When the time comes to test your shopping cart on Solaris, there's a problem. When the shopping cart tries to send the confirmation email, you get this error message:

    Call to undefined function: mail()

    What can you do to fix this problem?

    A.  Put an @ symbol in front of your call to mail() so that PHP does not output the error message.

    B.  Put sendmail back on the machine. Postfix doesn't provide a sendmail wrapper anyway.

    C.  Use mb_send_mail() instead.

    D.  Recompile PHP—after asking your network administrator to leave the MTA alone until the recompilation of PHP has completed

    The correct answer is D.

  3. All the new customers you're attracting on Solaris are very pleased with your shopping cart. Your product is earning them a lot of new customers also.

    However, like all customers, they want new features. Specifically, they want you to create and attach a simple comma-separated file that users can import into products such as Microsoft Money. This will make it easier for customers to manage their finances. Besides, it's a cool feature that none of your competitors have, so the marketing department has told your boss to get it done.

    At the moment, the shopping cart sends out RFC-822–compliant plain-text emails. What do you need to change to make it send the attachment as well?

    Choose from one of the following:

    A.  Replace your plain-text emails with MIME-encoded emails.

    B.  Refuse to do it. RFC-822 doesn't allow attachments, and your company should not be shipping products that go against Internet standards.

    C.  Put the CSV file on a web server, and put a link to it in the email.

    D.  Ditch PHP's built-in mail() function, and use the system() command to call sendmail directly.

    The correct answer is A.

  4. A rival has just launched a new version of his shopping cart. Unlike yours—which only sends plain-text emails—his shopping cart sends out confirmation emails that look more like a web page. These emails look so much nicer, and he's starting to eat into your sales as a result. It's a good thing his cart only runs on Windows; otherwise, you'd have no customers left!

    Something must be done, and marketing has decided that if you can't beat them, join them. Your long-suffering boss has been told to make your shopping cart send out nice-looking emails too. In the best tradition of pointy-haired bosses, he's dumped the whole problem in your lap, and is waiting for you to tell him how this can be done.

    What could you do to make this work? Choose one or more of the following:

    A.  Change your emails to send text/html MIME-encoded emails.

    B.  It's time to ditch mail() again and call sendmail directly.

    C.  Change your emails to send text/enriched MIME-encoded emails.

    D.  Tell your boss that this only works on Windows because PHP on Windows handles emails very differently.

    The correct answers are A and C.

  5. During testing of your new, much nicer-looking confirmation emails, you notice that there's a problem. The email uses quite a few images—including the all-important company logo. All of these images are stored on your web server, and the email uses standard "<img src=...>" tags to include them. The images look great in your email client—but appear as missing images when you send the email to your boss to show him the results of your hard work.

    Your boss isn't pleased, and neither is the marketing department, who make it very clear that you can't ship the code until the company logo shows up.

    The good news is that it isn't just your email. The confirmation emails sent by your rival also have this problem. If you can figure out how to make it work, not only will you be playing catch-up to your rival, but you'll also be back in the lead. This mollifies your boss, but gets you nowhere nearer to solving the problem.

    What could you change to make this work? Choose one or more of the following:

    A.  sendmail is too old. Replace it with a modern MTA instead.

    B.  Add all the images to the email as attachments with Content-Locations, and make your email use the attachments rather than the images on the website.

    C.  Add a piece of inline JavaScript in your email that temporarily changes the security settings of the email client. This will enable the images to be downloaded.

    D.  File a bug with the author of the email client that your boss uses. Something must be wrong with the way it handles RFC-1896–compliant email messages.

    The correct answer is B—and only B.

  6. With all the problems overcome, your company's shopping cart now sends email messages that not only look great, but also work where your rival's do not. Marketing is pleased, and has awarded your boss a bonus in return. Isn't that typical?

    However, the support team leader isn't happy. Since the release of your latest shopping cart marvel, there has been a large increase of bug reports about your new style email messages. It seems that many users won't accept HTML emails at all, and would like to be able to send plain-text emails instead.

    Seeing as he just got a nice bonus for adding HTML emails, your boss isn't too sympathetic to the idea of getting rid of them again. In desperation, the support team leader turns to you, and asks you to convince your boss.

    Draft out a short email message to your boss, explaining why plain-text emails are a good idea. As all consultants need to be politicians at heart, it might help to think about how you can keep both your boss and the support team leader happy.

>>> More PHP Articles          >>> More By Sams Publishing

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: