sending html email with xampp?

Problems with the Windows version of XAMPP, questions, comments, and anything related.

sending html email with xampp?

Postby unitedtrit » 14. August 2007 17:47

ive been trying to send an html email from a web form but for some reason it doesnt send the email when I try with xampp

it works just fine on my personal server but when i try on a xampp server it just gives an error and wont send the email

the email consists of a body which is basically a table with information from the forms fields, and then it adds an attachment (resume) to the email and sends it

im using a php script to generate and send the email with the attached resume

the xampp server has php5 and my server has php 4.4.7

we tried mercury mail with xampp for the attachment part and it sends fine but trying to send the table gives us an error
unitedtrit
 
Posts: 10
Joined: 14. August 2007 17:37

Postby Wiedmann » 14. August 2007 17:52

when i try on a xampp server it just gives an error
...
but trying to send the table gives us an error

Nonbody can know, which errors you have...
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby unitedtrit » 14. August 2007 18:00

This is the actually code that sends the email

Code: Select all
$ok = @mail($baseEmail, "New application awating review", $message, $headers);
if ($ok) {
  echo "<p>Mail sent! Yay PHP!</p>";
} else {
  echo "<p>Mail could not be sent. Sorry!</p>";
}


The message that we get is .. you guessed it, "mail could not be sent". When looking on the mercury admin i can see the smtp server being hit and it says:

Connection from 127.0.0.1
HELO ComputerName
MAIL FROM: addy@domain.com
QUIT

and just stops right there. we have some other code that is very basic and does not send html, but it does have file attachment support and it works fine on the xampp server using mercury.

When we tried to send just a basic single cell table the html tags showed up in the email instead of the table it's self.
unitedtrit
 
Posts: 10
Joined: 14. August 2007 17:37

Postby Wiedmann » 14. August 2007 18:05

You see the "@" operator in front of the mail() function?
--> You don't want see any error message...
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby unitedtrit » 14. August 2007 18:07

could you explain a little? I'm not the one writing the code, just the IT support, the @ is hiding an echo prehaps similar to batch file coding?
unitedtrit
 
Posts: 10
Joined: 14. August 2007 17:37

Postby Wiedmann » 14. August 2007 18:25

the @ is hiding an echo prehaps similar to batch file coding?

http://de.php.net/manual/en/language.op ... ontrol.php

--> remove the "@" to see the PHP error message (if there is any).
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby unitedtrit » 14. August 2007 18:32

when i remove the @ i get the following:

Warning: mail() [function.mail]: SMTP server response: 503 No valid recipients specified. in C:\Program Files\xampp\htdocs\test\mail.php on line 253

Mail could not be sent. Sorry!

Code: Select all
$ok = mail($baseEmail, "New application awating review", $message, $headers);
if ($ok) {
  echo "<p>Mail sent! Yay PHP!</p>";
} else {
  echo "<p>Mail could not be sent. Sorry!</p>";
}


is on that line
unitedtrit
 
Posts: 10
Joined: 14. August 2007 17:37

Postby Wiedmann » 14. August 2007 18:34

There is no or a wrong value in the variable "$baseEmail".

BTW:
Where did you define the values for the variables $baseEmail, $message and $headers?
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby unitedtrit » 14. August 2007 18:39

ok this may be alot but this is the mail.php script

Code: Select all
<html>
<head>
<title> Sending Email </title>
</head>
<body>
<?php
// Read POST request params into global vars


$to      = $_POST['baseEmail'];
$from    = $_POST['from'];
$pageLoc = $_POST['pageLoc'];
$pageLoc2 = $_POST['pageLoc2'];

$Name = $_POST['Name'];
$Phone = $_POST['Phone'];
$AltPhone = $_POST['AltPhone'];
$Email = $_POST['Email'];
$Address = $_POST['Address'];
$City = $_POST['City'];
$State = $_POST['State'];
$Zip = $_POST['Zip'];
$Internet = $_POST['Internet'];
$FootPedal = $_POST['FootPedal'];
$Windows = $_POST['Windows'];
$FTorPT = $_POST['FTorPT'];
$EMPorIC = $_POST['EMPorIC'];
$AnyTime = $_POST['AnyTime'];
$MShift = $_POST['MShift'];
$TShift = $_POST['TShift'];
$WShift = $_POST['WShift'];
$THShift = $_POST['THShift'];
$FShift = $_POST['FShift'];
$SShift = $_POST['SShift'];
$SUShift = $_POST['SUShift'];
$CurrentEMP = $_POST['CurrentEMP'];
$CurrentEMP2 = $_POST['CurrentEMP2'];
$AvailableToStart = $_POST['AvailableToStart'];
$OtherUsers = $_POST['OtherUsers'];
$Experience = $_POST['Experience'];
$EmergencyRoom = $_POST['EmergencyRoom'];
$OperativeReports = $_POST['OperativeReports'];
$DischargeSummaries = $_POST['DischargeSummaries'];
$Consultations = $_POST['Consultations'];
$HistoryandPhysicals = $_POST['HistoryandPhysicals'];
$ClinicNotes = $_POST['ClinicNotes'];
$GeneralPractice = $_POST['GeneralPractice'];
$EditingQA = $_POST['EditingQA'];
$SupervisorLeadMT = $_POST['SupervisorLeadMT'];
$Other = $_POST['Other'];
$LinesPerHour = $_POST['LinesPerHour'];
$RefLib = $_POST['RefLib'];
$Equipment = $_POST['Equipment'];
$ProfessionalReferences = $_POST['ProfessionalReferences'];
$IAuthorize = $_POST['IAuthorize'];


// Obtain file upload vars
$fileatt      = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];



$message = "<p>&nbsp;</p>
<table width=\"800\" border=\"1\" cellspacing=\"0\">
  <tr>
    <td colspan=\"11\">Name: <strong>$Name</strong></td>
  </tr>
  <tr>
    <td colspan=\"4\"> Phone #: <strong>$Phone</strong></td>
    <td colspan=\"4\">Alternate phone#: <strong>$AltPhone</strong></td>
  </tr>
  <tr>
    <td colspan=\"11\">Email: <strong>$Email</strong></td>
  </tr>
  <tr>
    <td colspan=\"11\">Address: <strong>$Address</strong></td>
  </tr>
  <tr>
    <td colspan=\"11\"><strong>$City, $State&nbsp;&nbsp;&nbsp;&nbsp;$Zip</strong></td>
  </tr>
  <tr>
    <td colspan=\"11\">&nbsp;</td>
  </tr>
  <tr>
    <td colspan=\"8\">High speed internet? <strong>$Internet</strong></td>
  </tr>
  <tr>
    <td colspan=\"8\">I have a <strong>$FootPedal</strong></td>
  </tr>
  <tr>
    <td colspan=\"8\">I use: <strong>$Windows</strong></td>
  </tr>
  <tr>
    <td colspan=\"8\">I want to work: <strong>$FTorPT</strong></td>
  </tr>
  <tr>
    <td colspan=\"8\">I am primarily interested in working as an: <strong>$EMPorIC</strong></td>
  </tr>
  <tr>
    <td colspan=\"8\"><strong>$AnyTime</strong></td>
  </tr>
  <tr>
    <td colspan=\"11\">&nbsp;</td>
  </tr>
  <tr>
    <td colspan=\"11\"><u>I am avaiable:</u></td>
  </tr>
  <tr>
    <td width=\"30\">DAY:</td>
    <td><u><strong>Monday</strong></u></td>
    <td><u><strong>Tuesday</strong></u></td>
    <td><u><strong>Wednesday</strong></u></td>
    <td><u><strong>Thursday</strong></u></td>
    <td><u><strong>Friday</strong></u></td>
    <td><u><strong>Saturday</strong></u></td>
    <td><u><strong>Sunday</strong></u></td>
  </tr>
  <tr>
    <td>SHIFT:</td>
    <td><strong>$MShift</strong></td>
    <td><strong>$TShift</strong></td>
    <td><strong>$WShift</strong></td>
    <td><strong>$THShift</strong></td>
    <td><strong>$FShift</strong></td>
    <td><strong>$SShift</strong></td>
    <td><strong>$SUShift</strong></td>
  </tr>
  <tr>
    <td colspan=\"11\">&nbsp;</td>
  </tr>
  <tr>
    <td colspan=\"11\">&nbsp;</td>
  </tr>
  <tr>
    <td colspan=\"8\">I am currently employed: <strong>$CurrentEMP</strong></td>
  </tr>
  <tr>
    <td colspan=\"8\">I am interested in <strong>$CurrentEMP2</strong> this job.</td>
  </tr>
  <tr>
    <td colspan=\"8\">I am avaiable to start: <strong>$AvailableToStart</strong></td>
  </tr>
  <tr>
    <td colspan=\"8\">Does anyone else use your computer? <strong>$OtherUsers</strong></td>
  </tr>
  <tr>
    <td colspan=\"8\">I have <strong>$Experience</strong> years of experience as a transcriptionist.</td>
  </tr>
  <tr>
    <td colspan=\"8\">&nbsp;</td>
  </tr>
  <tr>
    <td colspan=\"8\"><u>I have experience in:</u></td>
  </tr>
  <tr>
    <td colspan=\"4\">Emergency room: <strong>$EmergencyRoom</strong></td>
    <td colspan=\"4\">Operative Reports: <strong>$OperativeReports</strong></td>
  </tr>
  <tr>
    <td colspan=\"4\">Discharge Summaries: <strong>$DischargeSummaries</strong></td>
    <td colspan=\"4\">Consultations: <strong>$Consultations</strong></td>
  </tr>
  <tr>
    <td colspan=\"4\">History and physicals: <strong>$HistoryandPhysicals</strong></td>
    <td colspan=\"4\">Clinic Notes: <strong>$ClinicNotes</strong></td>
  </tr>
  <tr>
    <td colspan=\"4\">General Practice: <strong>$GeneralPractice</strong></td>
    <td colspan=\"4\">Editing/ QA: <strong>$EditingQA</strong></td>
  </tr>
  <tr>
    <td colspan=\"4\">Supervisor/ Lead MT: <strong>$SupervisorLeadMT</strong></td>
    <td colspan=\"4\">Other: <strong>$Other</strong></td>
  </tr>
  <tr>
    <td colspan=\"4\">&nbsp;</td>
    <td colspan=\"4\">&nbsp;</td>
  </tr>
  <tr>
    <td colspan=\"8\">Average lines transcribed per hour: <strong>$LinesPerHour</strong></td>
  </tr>
  <tr>
    <td colspan=\"8\">I <strong>$RefLib</strong> a good reference library.</td>
  </tr>
  <tr>
    <td colspan=\"8\">&nbsp;</td>
  </tr>
  <tr>
    <td colspan=\"8\">I own the following equipment for an at home position:</td>
  </tr>
  <tr>
    <td colspan=\"8\"><strong>$Equipment</strong></td>
  </tr>
  <tr>
    <td colspan=\"8\">&nbsp;</td>
  </tr>
  <tr>
    <td colspan=\"8\">Professional References:</td>
  </tr>
  <tr>
    <td colspan=\"8\"><strong>$ProfessionalReferences</strong></td>
  </tr>
  <tr>
    <td colspan=\"8\">I <strong>$IAuthorize</strong> United to contact my references.</td>
  </tr>
  <tr>
    <td colspan=\"8\">&nbsp;</td>
  </tr>
</table>";


$headers = "From: $from";

if (is_uploaded_file($fileatt)) {
  // Read the file to be attached ('rb' = read binary)
  $file = fopen($fileatt,'rb');
  $data = fread($file,filesize($fileatt));
  fclose($file);

  // Generate a boundary string
  $semi_rand = md5(time());
  $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
 
  // Add the headers for a file attachment
  $headers .= "\nMIME-Version: 1.0\n" .
              "Content-Type: multipart/mixed;\n" .
              " boundary=\"{$mime_boundary}\"";

  // Add a multipart boundary above the plain message
  $message = "This is a multi-part message in MIME format.\n\n" .
             "--{$mime_boundary}\n" .
             "Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
             "Content-Transfer-Encoding: 7bit\n\n" .
             $message . "\n\n";

  // Base64 encode the file data
  $data = chunk_split(base64_encode($data));

  // Add file attachment to the message
  $message .= "--{$mime_boundary}\n" .
              "Content-Type: {$fileatt_type};\n" .
              " name=\"{$fileatt_name}\"\n" .
              //"Content-Disposition: attachment;\n" .
              //" filename=\"{$fileatt_name}\"\n" .
              "Content-Transfer-Encoding: base64\n\n" .
              $data . "\n\n" .
              "--{$mime_boundary}--\n";
}

// Send the message
$ok = mail($baseEmail, "New application awating review", $message, $headers);
if ($ok) {
  echo "<p>Mail sent! Yay PHP!</p>";
} else {
  echo "<p>Mail could not be sent. Sorry!</p>";
}
?>
</body>
</html>


It is getting the baseEmail from the associated app.html file
unitedtrit
 
Posts: 10
Joined: 14. August 2007 17:37

Postby unitedtrit » 14. August 2007 18:43

ok i changed the $baseEmail out with a static email addy since it will never change anyway.

The email did send but it did not translate into html code for the email, just a bunch of html tags.
unitedtrit
 
Posts: 10
Joined: 14. August 2007 17:37

Postby Wiedmann » 14. August 2007 18:43

Can you see the variable "$baseEmail" a second time in this script? I not. (This variable is the recipient)
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby unitedtrit » 14. August 2007 18:47

yes i changed it out with a static email addy, read above your last post...i thank you very much for you help in this matter but i can not for the life of me figure out why it's just showing up as a bunch of html tags and not a table in the email.l


The guy who wrote the code uses 1&1.com as his host and everything works fine as is coming from his hosting provider.

is there a setting in mercury that I need to change so that it will translate the html?
unitedtrit
 
Posts: 10
Joined: 14. August 2007 17:37

Postby Wiedmann » 14. August 2007 18:58

i can not for the life of me figure out why it's just showing up as a bunch of html tags and not a table in the email.

Headers must be seperated with CRLF not only LF.[/quote]
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby unitedtrit » 14. August 2007 19:07

I'm not sure what you mean there, could to post a small code snippet to demonstrate please?
unitedtrit
 
Posts: 10
Joined: 14. August 2007 17:37

Postby Dave_L » 14. August 2007 23:50

Replace "\n" with "\r\n".

Example:

Code: Select all
// Add the headers for a file attachment
  $headers .= "\nMIME-Version: 1.0\n" .
              "Content-Type: multipart/mixed;\n" .
              " boundary=\"{$mime_boundary}\"";


Should be:

Code: Select all
// Add the headers for a file attachment
  $headers .= "\r\nMIME-Version: 1.0\r\n" .
              "Content-Type: multipart/mixed;\r\n" .
              " boundary=\"{$mime_boundary}\"";
User avatar
Dave_L
 
Posts: 212
Joined: 23. October 2004 00:43

Next

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 137 guests