Hi friends, i tried to send a mail using phpmailer class, but it throws an error "Mailer Error: Could not instantiate mail function." so i thought to use mail() function of php but i got a blank page. so what is the actual problem? this is code i used: <?php require("classes/class.phpmailer.php"); $mail = new PHPMailer(); // defaults to using php "mail()" //$body = file_get_contents('contents.html'); //$body = eregi_replace("[\]",'',$body); $body="its working hio!"; $mail->AddReplyTo("look4guna@hiox.com","First Last"); $mail->SetFrom('look4guna@hiox.com', 'First Last'); $mail->AddReplyTo("look4guna@hiox.com","First Last"); $address = "guna@hiox.com"; $mail->AddAddress($address, "GunaVK"); $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.gif"); // attachment //$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } ?> can anybody get me out of this problem? Thanks
Are you running it locally or on a server ? Locally it doesn't work for me either , because it can't deliver the email using mail()... Thats why it throws that error. Here's my code. <?php require("classes/class.phpmailer.php"); $mail = new PHPMailer(); $bodyHTML = "<h1>Its working hio!</h1>"; $bodyTXT = "Its working hio!"; $mail->SetFrom('look4guna@hiox.com', 'First Last',1); $mail->AddAddress("guna@hiox.com", "GunaVK"); $mail->Subject = "PHPMailer Test Subject via mail(), basic"; $mail->Body = $bodyHTML; $mail->AltBody = $bodyTXT; $mail->isHTML(true); if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } ?> PHP:
I think you're right tvoodoo. I tried to run it locally. I didn't that much about mail related concepts, so the same will run if we put it into a server ah? do we need any permissions from the hosting company to send mails?