As advised I have tried using PHP Mailer to send email attachments with a form, however I keep getting the error message “Mailer Error: Could not instantiate mail function.
I have rechecked the email address and cannot find any error for same
here is the code for the PHP as well as the code for the form. Any input is greatly appreciated. Thanks, JB
<html>
<head>
<title>PHPMailer - Mail() basic test</title>
</head>
<body>
<?php
require_once('class.phpmailer.php');
$mail = new PHPMailer(); // defaults to using php "mail()"
$body = file_get_contents('talent3.html');
$body = eregi_replace("[\]",'',$body);
$mail->AddReplyTo("jbgraphics@rogers.com","First Last");
$mail->SetFrom('jbgraphics@rogers.com', 'First Last');
$mail->AddReplyTo("jbgraphics@rogers.com","First Last");
$address = "jbgraphics@rogers.com";
$mail->AddAddress($address, "John Beadle");
$mail->Subject = "PHPMailer Test Subject via mail(), basic";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAttachment("images/phpmailer.pdf"); // attachment
$mail->AddAttachment("images/phpmailer_mini.jpeg"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
</body>
</html>
and the form code:
<form action="test_mail_basic.php" method="post"
enctype="multipart/form-data">
<label for="file" class="bodyCopy"><span class="bodyCopy">Attach resume:</span></label><br />
<input type="file" name="attach1" id="file" /><br />
<br />
<label for="file" class="bodyCopy"><span class="bodyCopy">Attach photo:</span></label><br />
<input type="file" name="attach2" id="file" /><br />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
That error is a result of the php mail() function returning false.
Typically, it returns false if sendmail is not configured correctly in php.ini or if sendmail doesn’t exist on the server.
Are you running this on a Linux server or Windows? A very simple test to see if mail is working is to run this code:
If you are on Windows, you will likely need to use an SMTP server instead of php mail() so you will need to use SMTP as seen in this phpmailer SMTP example.
If you are on shared hosting, it may be that the message is being rejected because of some of the extra parameters being send to the mail function.