Hi, I’ve got a web-based form I’m trying to put together to send e-mails with attachments from a website, and I’m having trouble getting my process script to see the attachment’s variable.
Here’s the form:
[CODE]
<H2>Send e-mail mailout</H2>
<FORM ACTION=”mailout/processmailout2.php” METHOD=”POST” ENCTYPE=”multipart/form-data”>
<TABLE>
<TR><TD>Recipient mailing mist: </TD>
<TD><SELECT NAME=”recipientlist”>
<OPTION VALUE=”” SELECTED></OPTION>
<OPTION VALUE=”list1″>Vegenotes</OPTION>
<OPTION VALUE=”list2″>VegLink</OPTION>
<OPTION VALUE=”list3″>Vegetable Platter</OPTION>
<OPTION VALUE=”list4″>Good Fruit & Veg</OPTION>
<OPTION VALUE=”list5″>Diamond back Moth</OPTION>
</SELECT></TD></TR>
<TR><TD>Subject:</TD><TD><INPUT TYPE=”text” NAME=”subject” SIZE=”70″></TD></TR>
<TR><TD>Attachment:</TD><TD><INPUT TYPE=”file” NAME=”attchmnt” SIZE=”60″></TD></TR>
</TABLE>
Message:<BR>
<TEXTAREA NAME=”message” COLS=”80″ SIZE=”5″></TEXTAREA><BR>
<INPUT TYPE=”submit” VALUE=”Send”>
</FORM>
processmailout.php is the script I’m using to handle the actual sending once the form is filled out, and this is it below.
[code=php]
<?php
//processcreate.php is the script responsible for processing the data from
//the createprofile.php form after it has been verified by the JS checker
//and then updates the database as appropriate.
require(“class.phpmailer.php”);
$mailer = new PHPMailer();
$mailer->From = “from@address”;
$mailer->FromName = “name”;
$mailer->Host = “our.host.com.au”;
$mailer->Mailer = “smtp”;
$mailer->Body = $message;
$mailer->Subject = $subject;
$mailer->Username = “user”;
$mailer->Password = “pass”;
if ($attchmnt != “”) {
if ($mailer->AddAttachment($attchmnt)) {
echo “attached”;
} else {
echo “failed: ” . $mailer->ErrorInfo.”<BR>”;
}
} else {
echo “no attachment!”;
}
$to = “[email protected]”;
$name = “Recipient name”;
$mailer->AddAddress($to,$name);
if (!($mailer->Send())) {
echo “Not sent for $name <$to><BR>”;
}
$mailer->ClearAddresses();
?>
The output from this processmailout.php script is “no attachment!”, so I’m not too sure what’s goin wrong.
The file “class.mailer.php” is the PHPMailer script from [URL]http://phpmailer.sourceforge.net
Anyone with any tips/suggestions would be greatly appreciated.
?
edit: Solved it by using $_FILES properly. My script to replace $