PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Lots of people call wanting this emailed and faxed (just need to save as txt file to a directory and my fax server will take it from there) to them so I am working on a couple of scripts that would allow me to submit a form from our office that would run the script and email as an attachment (or save as txt). I have been playing with it but so far I have nothing that will work.
Does anyone know what direction I should go?
On a related note I have been trying to just recreate the output inside of an html email but so far all I can get is the last result to show in the email. Here is the code:
if ($type = 1) {
$mail->Subject = "Your requested Unrooted Availabilty from North Carolina Farms Inc";
$query = "select * FROM avail WHERE Type=2";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
// HTML body
$body = "" . $row["name"] . "" . $row["one"] . "" . $row["two"] . "";
}
// Plain text body (for mail clients that cannot read HTML)
$text_body = "will have text here";
} elseif ($type = 2) {
} else {
}
$mail->Body = $body;
$mail->AltBody = $text_body;
$mail->AddAddress($add);
if(!$mail->Send()) {
echo "<font color='ffffff' face='arial'>Failed to send mail. Check your address again.";
} else {
echo "<font color='ffffff' face='arial'>Availability sent to '$add'";
}
I didn't throw in the headers and everything because everything is working fine except that it only reports the last entry that matches the select statement.
Any ideas?
Another solution that I have found is a script that was written by someone at planteozh.
It does a great job. If you have problems with not being able to load the file just make sure your dir is relative (../dir) and not a full url and chmod (777).
I am off to adapt it to my needs now.
Thanks for the suggestions.
I little update if any stumbles on to this post looking for an email solution. This is a code that I found emails the executed page as attached variable (works will phpmailer and swiftmailer)