University of Bahrain

Information Technology College

Computer Science Department

Semester 1, Year 2006/2007

ITCS 373: Class Lab Work

E-commerce3

 

 

Instructor: Dr. Eshaa M. Alkhalifa

 

Now that an email server is running properly we can go back to our script to learn how to customize it to work with our email server.

 

  1. Start by running it and issuing an order, to find the following error instructions.

Warning: mail() [function.mail]: SMTP server response: 501 <"My Store"<ealkhalifa@admin.uob.bh>>: "@" or "." expected after ""My Store"" in C:\AppServ\www\ShopScript\includes\order_place.php on line 83

Warning: mail() [function.mail]: SMTP server response: 501 <"My Store"<ealkhalifa@admin.uob.bh>>: "@" or "." expected after ""My Store"" in C:\AppServ\www\ShopScript\includes\order_place.php on line 88

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\ShopScript\includes\order_place.php:83) in C:\AppServ\www\ShopScript\includes\order_place.php on line 94

  1. These result if the settings of the store are as follows

  1. Modify the email fields to reflect the address you are sending from using your local email server, so they will be as follows;

  1. Try to make another puchase order.  You are still likely to get the following error messages.

Warning: mail() [function.mail]: SMTP server response: 501 <"myemail"<myemail@localhost.com>>: "@" or "." expected after ""myemail"" in C:\AppServ\www\ShopScript\includes\order_place.php on line 83

Warning: mail() [function.mail]: SMTP server response: 501 <"myemail"<myemail@localhost.com>>: "@" or "." expected after ""myemail"" in C:\AppServ\www\ShopScript\includes\order_place.php on line 88

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\ShopScript\includes\order_place.php:83) in C:\AppServ\www\ShopScript\includes\order_place.php on line 94

  1. Take a look at the first error message.  Try to understand where the error is located.  It seems that the shopping cart is attempting to send an email, to the customer in the first line.  The words myemail reflect the name of the store, and the myemail@localhost.com is the email address that we are using for the store.
  2. This means that our server is not recognizing the php code, for sending a name separate from the email address.  We can fix this, by opening the file that is called order_place.php which you will find in the directory shown above.
  3. Go to line 83 to find;

mail($_POST["email"], EMAIL_CUSTOMER_ORDER_NOTIFICATION_SUBJECT, $smarty_mail->fetch("order_notification.tpl.html"), "From: \"".CONF_SHOP_NAME."\"<".CONF_GENERAL_EMAIL.">\n".stripslashes(EMAIL_MESSAGE_PARAMETERS)."\nReturn-path: <".CONF_GENERAL_EMAIL.">");

Replace this line with

mail($_POST["email"], EMAIL_CUSTOMER_ORDER_NOTIFICATION_SUBJECT, $smarty_mail->fetch("order_notification.tpl.html"), "From: ".CONF_GENERAL_EMAIL."\n".stripslashes(EMAIL_MESSAGE_PARAMETERS)."\nReturn-path: <".CONF_GENERAL_EMAIL.">");

  1. Did you see what I did?  I removed the name that is placed in front of the email address and left the rest as is.
  2. Now try to make another order but make sure that the customer email address you insert is correct.  Check that you receive the email sent by your store.
  3. Can you now fix the second error line?  You can modify it in the same way you modified the one above but you must in this case search for the different and correct it as appropriate.
  4. Challenge:  What does the third line indicate and does the error remain after modifying the second line.
  5. Congratulations!!  You should now have your shopping cart working and should be able to connect it to a merchant account and a payment gateway.