PHP email troubles

Hello -
I am still learning php.  I am trying to send 2 emails once a form is submitted.  I have commented out the section I am having problems with.  Can anyone help?

    // -- selects who to send the email to.  
    $varHRTO = "mt9839@att.com";
    $varREFTO ="m34475@att.com";

   // -- This will be the subject in the email
    $varHRSUBJECT  = "New HORIZONS Application for " . $_POST['lastname'] . " submitted on $date";
    $varREFSUBJECT = "New HORIZONS Application for " . $_POST['lastname'] . " submitted on $date";


    // To send HTML mail, the Content-type header must be set
    $HEADERS  = "Content-type: text/html\r\n";
    $HEADERS .= "From:  swbstaffing@txmail.sbc.com \r\n";

    //-- Two emails will be sent out one to the Horizons Team and one to Horizons Manager.

    //-- Start of email

    $varMESSAGE    = "<html><head></head><body>";
    $varHRMESSAGE  = $varMESSAGE;
    $varREFMESSAGE = $varMESSAGE;


    //-- Salutation of email

  //  $varHRMESSAGE .  = "A Non-Management Employee referral from the HORIZONS website has been submitted.";
 //   $varREFMESSAGE . = "Thank you for taking the time to refer this candidate!";


    //-- this is the contents of the form

  //  $varMESSAGE . = "<br /><br /><strong>Applicant Last Name:</strong> ". $_POST['lastname'] .
                      "<br /><br /><strong>Applicant First Name:</strong> ". $_POST['firstname'] .
                      "<br /><br /><strong>Applicant Middle Initial:</strong> ". $_POST['middle'] .
                      "<br /><br /><strong>Applicant PRNRS:</strong> ". $_POST['prnrs'] .
                      "<br /><br /><strong>Applicant Street Number:</strong> ". $_POST['number'] .
                      "<br /><br /><strong>Applicant Street Address:</strong> ". $_POST['street'].
                      "<br /><br /><strong>Apt Number:</strong> ". $_POST['apt'].
                      "<br /><br /><strong>Applicant City:</strong> ". $_POST['city'].
                      "<br /><br /><strong>Applicant State:</strong> " . $_POST['state'].
                      "<br /><br /><strong>Applicant Zip Code:</strong> " . $_POST['zip'] .
                      "<br /><br /><strong>Applicant Union Local:</strong> ". $_POST['localunion'] .
                      "<br /><br /><strong>Applicant NCS:</strong> ". $_POST['ncs'] .
                      "<br /><br /><strong>Applicant Work Phone:</strong> ". $_POST['workphone'] .
                      "<br /><br /><strong>Applicant Home Phone:</strong> ". $_POST['home'].
                      "<br /><br /><strong>Date of Applicant Separation:</strong> ". $_POST['separation'].
                      "<br /><br /><strong>Applicant RC Code:</strong> ". $_POST['rc'].
                      "<br /><br /><strong>Applicant Fax:</strong> ". $_POST['fax'].
                      "<br /><br /><strong>Applicant Other Contact Number:</strong> " . $_POST['other'].
                      "<br /><br /><strong>Applicant Current Job Title:</strong> " . $_POST['job'].
                      "<br /><br /><strong>Does Applicant Have a 4 Year Degree:</strong> " . $_POST['degree'] .
                      "<br /><br /><strong>Is Applicant on Disability or Leave:</strong> ". $_POST['leave'] .
                      "<br /><br /><strong>Course Objective:</strong> ". $_POST['objective'] .
                      "<br /><br /><strong>Course Start Date:</strong> ". $_POST['start_date'] .
                      "<br /><br /><strong>Course Completion Date:</strong> ". $_POST['completion'].
                      "<br /><br /><strong>Course Number:</strong> ". $_POST['course'].
                      "<br /><br /><strong>Course Units:</strong> ". $_POST['units'].
                      "<br /><br /><strong>Course Title:</strong> ". $_POST['title'].
                      "<br /><br /><strong>Course Major:</strong> " . $_POST['major'].
                      "<br /><br /><strong>Name of Provider:</strong> " . $_POST['provider'].
                      "<br /><br /><strong>Provider Address:</strong> " . $_POST['address'].
                      "<br /><br /><strong>Provider Phone Number:</strong> " . $_POST['phone'] .
                      "<br /><br /><strong>Provider fax Number:</strong> ". $_POST['providerfax'] .
                      "<br /><br /><strong>Contact Person At School:</strong> ". $_POST['contact'] .
                      "<br /><br /><strong>Tuition Fees:</strong> ". $_POST['tuition'] .
                      "<br /><br /><strong>Required Book Fees:</strong> ". $_POST['books'].
                      "<br /><br /><strong>Required Fees:</strong> ". $_POST['fees'].
                      "<br /><br /><strong>Total Required:</strong> ". $_POST['total'].
                      "<br /><br /><strong>Conditions:</strong> ". $_POST['conditions'].
                      "<br /><br /><strong>Signature:</strong> " . $_POST['signature'].
                      "<br /><br /><strong>Signature Date:</strong> " . $_POST['date'];

    $varHRMESSAGE  .= $varMESSAGE;
    $varREFMESSAGE .= $varMESSAGE;

    //-- This is only for the HR administrator

    $varHRMESSAGE .= "<br /><br />Click <a href=\"https://".$_SERVER[HTTP_HOST]."/online_detail.php?id=$id\">here </a> to view database record.";


    //-- Closing of email
    $varMESSAGE     = "<br /><br />NMSIP - Webmaster<br /></body></html>";
    $varHRMESSAGE  .= $varMESSAGE;
    $varREFMESSAGE .= $varMESSAGE;

    //-- Send email out
    mail($varHRTO,  $varHRSUBJECT,  $varHRMESSAGE,  $varHEADERS);
    mail($varREFTO, $varREFSUBJECT, $varREFMESSAGE, $varHEADERS);
moette88Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hernst42Commented:
If you wantto send HTMl-mails I suggest you use http://phpmailer.sf.net which makes the sending of mails a lot more comfortable and without a lot of errors.

example:
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();                                   // send via SMTP
$mail->Host     = "smtp1.site.com;smtp2.site.com"; // SMTP servers
$mail->From     = "from@email.com";
$mail->FromName = "Mailer";
$mail->AddAddress("josh@site.com","Josh Adams");
$mail->AddAddress("ellen@site.com");               // optional name
$mail->AddReplyTo("info@site.com","Information");
0
moette88Author Commented:
My only issue is that I have to use our department server which is through my phpadmin - joomla.  I am mirroring coding that was used in a similar form.  The person is not available to ask.  Is there anyway I can get this to work?
0
hernst42Commented:
So whats the problem excatly? Is the html not displayed when the message is received? So your headers might be incorrect. From http://php.net/mail
Maybe the headers are wrong:

$body="<em>HTML</em> formatted <strong>Message</strong";
   
$headers = "From: info@example.com \r\n";
$headers.= "Content-Type: text/html; charset=ISO-8859-1 ";
$headers .= "MIME-Version: 1.0 ";
/*notice there aren't any \r\n after the
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

moette88Author Commented:
When I "un-comment" the salutation and the contents of the form, my form no longer shows up and i get a parse error message.
0
Steve BinkCommented:
What is the parse error message?
0
moette88Author Commented:
Parse error: parse error in /appl/nmsi/html/ssl/horizons2/online_form.php on line 403
0
PatrickAdrichemCommented:
ok first off all don't make your mail so loooooong

if you send a mail like

thisismyuberlongmailforyoumadeandalll!!

some servers will not exept it. Break it up using "\n" (note the "" instead of the '');

further i don't see any real problems in what you posted except that if that varmessage is multilined you only comment the first part and not the rest, put it in /*    */ just to be sure when uncommenting
and you might try adding this to each line

$varMESSAGE . =
and close each line with ;
achieves the same result.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Steve BinkCommented:
No other information in the error message?  Are you getting this from the browser output or an error log?  Paste line 403 here, please.
0
PatrickAdrichemCommented:
Actually paste line 399 to 405 ;) might be an error in the line above. (like non closure)
0
moette88Author Commented:
Thanks - I will try.
Unfortunately I have to have a long email.  The email is suppose to show all of the information submitted on the form to the processing workgroup.
0
PatrickAdrichemCommented:
The long e-mail is not a problem. You must however break it with line breaks ("\n") so that the email program will recieve it in multiple lines instead of just 1 huge line.
0
moette88Author Commented:
Thanks!  Do i need to put the "\n" on each line?
0
PatrickAdrichemCommented:
I'd suggest on each line where you'd normally break it up by pressing enter.
0
hernst42Commented:
The problem with you commented lines is that you put spaces between . and = which leead to parse errors:

  //  $varHRMESSAGE .  = "A Non-Management Employee referral from the HORIZONS website has been submitted.";
 //   $varREFMESSAGE . = "Thank you for taking the time to refer this candidate!";
shouldb be:

  $varHRMESSAGE .= "A Non-Management Employee referral from the HORIZONS website has been submitted.";
  $varREFMESSAGE .= "Thank you for taking the time to refer this candidate!";


0
moette88Author Commented:
Excellent!  thank you.  I wll try all suggestions this afternoon and get back to the both of you!  I'm excited.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

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.