Reputation: 1273
I am using phpmailer for a contactform with attachment and in the php i build my own error messages. the form and email work fine but when not filling in an email address and not chosen a file to upload i got these error messages from phpmailer
Invalid address: Could not access file:
This is the code of phpmailer i use now:
// Software: PHPMailer - PHP email class |
// Version: 5.1
require('phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = FALSE;
$mail->Port = 25;
$mail->Host = "localhost";
$mail->Mailer = "smtp";
$mail->SetFrom($_POST["user_email"], $_POST["user_name"]);
$mail->AddAddress("myname@myemailcom");
$mail->Subject = "Contactform";
$mail->WordWrap = 80;
$mail->MsgHTML($_POST["user_message"]);
if(is_array($_FILES)) {
$mail->AddAttachment($_FILES['user_attachment']['tmp_name'],$_FILES['user_attachment']['name']);
}
$mail->IsHTML(true);
if(!$mail->Send()) {
echo 'some error message';
}
else {
echo 'success message';
}
After some research i tried to add:
$phpmailer->SMTPDebug=false; // without result
How can i get rid of these built in error messages?
Upvotes: 0
Views: 280
Reputation: 37730
First of all you're running a very old version of PHPMailer that is dangerously outdated and is exposing your site to some major vulnerabilities. Before you do anything else, upgrade. I also suggest you base your code on the current examples provided with PHPMailer.
In the code you posted, you're not enabling debug output (it's off by default) at all, so I suspect there may be other code you're not showing. You have not shown what the debug output looks like, so we can't tell whether it's really PHPMailer that's generating it.
Your PHPMailer instance is called $mail
, not $phpmailer
, and the SMTPDebug
property is an integer, so change that line to:
$phpmailer->SMTPDebug = 0;
Upvotes: 1