Hi all.
I have been trying to send mail with an attachemnt and have run into a problem with the message body. I have tried using both mime_mail and sendmail classes and can use both to send emails with attachments successfully, but for some reason I can not get the message body to appear. I am currently using sendmail and have the following code to store the attachment and send the email:
include_once ("inc.upload.php");
include_once ("inc.sendmail.php");
$file = $_FILES['fileUpload'];
$name = $_POST['name'];
$to = 'emailAddress';
$to_title = 'Company Enquiry';
$subject = 'Company Appointments Enquiry - from company.co.uk';
$header = '';
$Upload = new Upload();
$Upload->setTheFile($file);
$Upload->setFilePath("uploadedFiles");
$Upload->setMaxFileSize("3000000");
$Upload->setAllowedTypes(array("application/msword",
"application/pdf",
"application/rtf",
"text/richtext",
"text/plain",
"application/excel",
"application/wordperfect",
"application/x-zip-compressed"));
if(!$Upload->doUpload()) {
print("Unacceptable file format!<BR>\n");
}
$message = sprintf ('<style type="text/css">
<!--
body {
font-family: tahoma,arial,sans-serif;
padding: 0px;
color: #000000;
background: #c9c9c9;
margin: 0px;
}
td {
font-family: tahoma, arial, sans-serif;
padding: 0px;
color: #000000;
background: none;
/* border: solid 1px #ff0000;*/
}
p {
margin-top: 3px;
font-size: 0.7em;
text-align: justify;
font-family: tahoma;
line-height: 1.5em;
padding: 3px;
}
.sub-titles {
font-weight: bold;
color: #FFFFFF;
background-color: #C1DAA7;
height: 30px;
text-align: center;
vertical-align: middle;
}
.padded-table {
padding: 8px;
border: 1px solid #999999;
margin: 8px;
background: #ffffff;
}
.padding {
}
-->
</style>
</head>
<body>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" class="padded-table">
<tr>
<td height="30" colspan="4"><span class="sub-titles">Enquiry from Opus Appointments Website</span></td>
</tr>
<tr>
<td width="29" valign="top"> </td>
<td width="99" valign="top"><p><strong>Name:</strong></p></td>
<td width="321" valign="top"><p>%s</p></td>
<td width="49"> </td>
</tr>
<tr>
<td width="29" valign="top"> </td>
<td width="99" valign="top"><p><strong>Email:</strong></p></td>
<td width="321" valign="top"><p>%s</p></td>
<td width="49"> </td>
</tr>
<tr>
<td width="29" valign="top"> </td>
<td height="28" valign="top"><p><strong>Telephone:</strong></p></td>
<td valign="top"><p>%s</p></td>
<td width="49"> </td>
</tr>
<tr>
<td width="29" valign="top"> </td>
<td valign="top"><p><strong>address:</strong></p></td>
<td valign="top"><p>%s</p></td>
<td width="49"> </td>
</tr>
<tr>
<td width="29" valign="top"> </td>
<td valign="top"><p><strong>availability:</strong></p></td>
<td valign="top"><p>%s</p></td>
<td width="49"> </td>
</tr>
<tr>
<td width="29" valign="top"> </td>
<td valign="top"><p><strong>transport:</strong></p></td>
<td valign="top"><p>%s</p></td>
<td width="49"> </td>
</tr>
<tr>
<td width="29" valign="top"> </td>
<td valign="top"><p><strong>position:</strong></p></td>
<td valign="top"><p>%s</p></td>
<td width="49"> </td>
</tr>
<tr>
<td width="29" valign="top"> </td>
<td valign="top"><p><strong>salary:</strong></p></td>
<td valign="top"><p>%s</p></td>
<td width="49"> </td>
</tr>
<tr>
<td colspan="4" valign="top"> </td>
</tr>
</table>
</body>
</html>', stripslashes($_POST['name']), stripslashes($_POST['email']), stripslashes($_POST['telephone']), stripslashes($_POST['address']), stripslashes($_POST['availability']), stripslashes($_POST['transport']), stripslashes($_POST['position']), stripslashes($_POST['salaryrange']));
$mail = new sendmail();
$mail->SetCharSet("ISO-8859-1");
$mail->from($name,stripslashes($_POST['email']));
$mail->to('emailAddress');
$mail->to('emailAddress');
$mail->subject($subject);
$mail->text($message);
$mail->attachment($Upload->getStoredFilePath());
$mail->send();
header ("Location:contact_us.php?thank=you");
Any ideas why the body text isn't showing?
Thank you.
Stephen.