Solved

Mailer Error: Could not instantiate mail function.

Posted on 2007-04-04
6
2,898 Views
Last Modified: 2013-12-13
$mail = new PHPMailer();
$mail->From = "ap@xxx.fi";
$mail->FromName = "Tarjouspyyntolomake";
$mail->AddAddress("xxxa@xxx.fi");
$mail->SetLanguage('en', 'language');


$mail->AddAttachment($_FILES['tiedosto1']['tmp_name'], basename($_FILES['tiedosto1']['name'])); // liitetiedosto 1
$mail->AddAttachment($_FILES['tiedosto2']['tmp_name'], basename($_FILES['tiedosto2']['name'])); // liitetiedosto 2
$mail->AddAttachment($_FILES['tiedosto3']['tmp_name'], basename($_FILES['tiedosto3']['name'])); // liitetiedosto 3
$mail->IsHTML(True);                               // viesti html, anna olla oletuksena.

$mail->Subject  =  $subject; //
$mail->Body     =  $message;

if(!$mail->Send())
{
   echo "Tarjouspyynt&ouml;si ei l&auml;hetetty <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
} else {
   echo "Tarjouspyynt&ouml;si on l&auml;hetetty";
   echo "<br><br>";
   echo "Sinut ohjataan Printstudion etusivulle";  
}
?>


 and i get next error message:

Mailer Error: Could not instantiate mail function. What is wrong
0
Comment
Question by:tikkanen
6 Comments
 
LVL 5

Expert Comment

by:richswyatt
ID: 18852955
Question - have you INCLUDE or REQUIRE 'd the class file holding the PHPMailer class?  My assumption is that you have not, given the error and the fact that it is missing from above.

If you have, then we'll go from there.
0
 
LVL 5

Expert Comment

by:NickVd
ID: 18852984
That error indicates that the PHPMailer class has not been loaded.  Make sure you include() or require() the library before you instantiate it.
0
 
LVL 50

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 18853066
On the contrary, the error indicated is coming FROM the PHPMailer class, specifically on line 445 inside PHPMailer->MailSend.  This method is called from PHPMailer->Send when the class is set to use PHP's built-in mail() function.  PHPMailer->Mailer is set to "mail" by default.

The return from the mail() function is simply true or false.  Success or failure.  The error being displayed does not necessarily mean the mail() call was unable to instantiate, but that it was unsuccessful in sending the mail for a variety of reasons.  

You can attempt debugging it by removing the '@' symbol on line 438.  The full line should then read:
    $rt = mail($to, $this->EncodeHeader($this->Subject), $body, $header);

That will allow actual errors generated in mail() to hit your PHP error log.  If that does not help, you'll have to be scouring your email server logs to find out why the message was not accepted.  Are you sure you have a mail service running on this server?
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:tikkanen
ID: 18856027
This form works just fine before.

When I removing @ symbol, i get following error message.
Warning: mail() [function.mail]: Failed to connect to mailserver at "mail.eunet.fi" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in c:\inetpub\wwwroot\class.phpmailer.php on line 438


Here is my action page code:
<html>
<head>
<title>Tarjouspyynt&ouml;</title>
<link href="css/basic.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript">
function redirect()
{
 window.location.href='http://www.printstudio.fi';
}
</script>
</head>
<body onload="setTimeout('redirect()', 3000)">
<?php
error_reporting(E_ALL ^ E_NOTICE);
    $message .= "Ty&ouml;nnimi/Viite: {$_POST['viite']}<br />";
    $message .= "Mihin menness&auml; oltava valmis: {$_POST['timestamp']}<br />";
     $message .= "Ohjelma: {$_POST['ohjelma']}<br />";
     $message .= "Tulostusvalmis: {$_POST['Tulostusvalmis']}<br />";
     
     if(isset($_POST['tuote_01_kpl']) && $_POST['tuote_01_kpl'] != '' ){      
     $message .= "Toimitusm&auml;&auml;r&auml;/tuote 1: {$_POST['tuote_01_kpl']} kappaletta<br />";
     $message .= "Tuotteen 1 Leveys: {$_POST['tuote_01_leveys']} mm <br />";
     $message .= "Tuotteen 1 korkeus: {$_POST['tuote_01_korkeus']} mm<br />";
     $message .= "Tuotteen 1 toistuvuus krt/vuosi: {$_POST['tuote_01_toistuvuus']} kertaa<br /><br />";
     }
     
     if(isset($_POST['tuote_02_kpl']) && $_POST['tuote_02_kpl'] != '' ){
     $message .= "Toimitusm&auml;&auml;r&auml;/tuote 2: {$_POST['tuote_02_kpl']} kappaletta<br />";
     $message .= "Tuotteen 2 Leveys: {$_POST['tuote_02_leveys']} mm <br />";
     $message .= "Tuotteen 2 korkeus: {$_POST['tuote_02_korkeus']} mm<br />";
     $message .= "Tuotteen 2 toistuvuus krt/vuosi: {$_POST['tuote_02_toistuvuus']} kertaa<br /><br />";
     }
     
     if(isset($_POST['tuote_03_kpl']) && $_POST['tuote_03_kpl'] != '' ){
     $message .= "Toimitusm&auml;&auml;r&auml;/tuote 3: {$_POST['tuote_03_kpl']} kappaletta<br />";
     $message .= "Tuoteen Leveys: {$_POST['tuote_03_leveys']} mm <br />";
     $message .= "Tuoteen korkeus: {$_POST['tuote_03_korkeus']} mm<br />";
     $message .= "Tuoteen toistuvuus krt/vuosi: {$_POST['tuote_03_toistuvuus']} kertaa<br /><br />";
     }
     
     if(isset($_POST['tuote_04_kpl']) && $_POST['tuote_04_kpl'] != '' ){
     $message .= "Toimitusm&auml;&auml;r&auml;/tuote 4: {$_POST['tuote_04_kpl']} kappaletta<br />";
     $message .= "Tuotteen 4 Leveys: {$_POST['tuote_04_leveys']} mm <br />";
     $message .= "Tuotteen 4 korkeus: {$_POST['tuote_04_korkeus']} mm<br />";
     $message .= "Tuotteen 4 toistuvuus krt/vuosi: {$_POST['tuote_04_toistuvuus']} kertaa<br /><br />";
     }
     if(isset($_POST['Tulostusmateriaali']) && $_POST['Tulostusmateriaali'] != '' ){
     $message .= "Tulostusmateriaali: {$_POST['Tulostusmateriaali']}<br />";
 }
 if(isset($_POST['Tulostusmateriaali_mik&auml;']) && $_POST['Tulostusmateriaali_mik&auml;'] != '' ){    
 $message .= "Tulostusmateriaali_muu mik&auml;: {$_POST['Tulostusmateriaali_mik&auml;']}<br />";
}
if(isset($_POST['Kayttoaika']) && $_POST['Kayttoaika'] != '' ){    
$message .= "K&auml;ytt&ouml;aika (kuukautta esill&auml;): {$_POST['Kayttoaika']}kk<br /><br />";
}
if(isset($_POST['Puhtaaksileikkaus']) && $_POST['Puhtaaksileikkaus'] != '' ){
     $message .= "Puhtaaksileikkaus: {$_POST['Puhtaaksileikkaus']}<br />";
 }
if(isset($_POST['Ritsaus']) && $_POST['Ritsaus'] != '' ){
     $message .= "Ritsaus: {$_POST['Ritsaus']}<br />";
 }
if(isset($_POST['Reijitys']) && $_POST['Reijitys'] != '' ){
     $message .= "Reijitys: {$_POST['Reijitys']}<br />";
}
if(isset($_POST['Taitto']) && $_POST['Taitto'] != '' ){
     $message .= "Taitto: {$_POST['Taitto']}<br />";
}
if(isset($_POST['Nuuttaus']) && $_POST['Nuuttaus'] != '' ){
     $message .= "Nuuttaus: {$_POST['Nuuttaus']}<br />";
 }
if(isset($_POST['Personointi']) && $_POST['Personointi'] != '' ){
     $message .= "Personointi: {$_POST['Personointi']}<br />";
 }
 if(isset($_POST['Numerointi']) && $_POST['Numerointi'] != '' ){
     $message .= "Numerointi: {$_POST['Numerointi']}<br />";
 }
 if(isset($_POST['Wiresidonta']) && $_POST['Wiresidonta'] != '' ){    
 $message .= "Wiresidonta: {$_POST['Wiresidonta']}<br />";
}
if(isset($_POST['Foliointi']) && $_POST['Foliointi'] != '' ){
     $message .= "Foliointi: {$_POST['Foliointi']}<br />";
 }
 if(isset($_POST['Stanssaus']) && $_POST['Stanssaus'] != '' ){
     $message .= "Stanssaus: {$_POST['Stanssaus']}<br />";
 }
 if(isset($_POST['kuumalaminointi']) && $_POST['kuumalaminointi'] != '' ){
     $message .= "Kuumalaminointi: {$_POST['kuumalaminointi']}<br />";
 }
 if(isset($_POST['kylmalaminointi']) && $_POST['kylmalaminointi'] != '' ){
       $message .= "Kylm&auml;laminointi: {$_POST['kylmalaminointi']}<br />";
}
if(isset($_POST['pussilaminointi']) && $_POST['pussilaminointi'] != '' ){
      $message .= "Pussilaminointi: {$_POST['pussilaminointi']}<br />";
}
if(isset($_POST['pohjustus_mainospahvi_selection']) && $_POST['pohjustus_mainospahvi_selection'] != '' ){
$message .= "Pohjustus: {$_POST['pohjustus_mainospahvi_selection']}<br />";
}
if(isset($_POST['pohjustus_kevytlevy_selection']) && $_POST['pohjustus_kevytlevy_selection'] != '' ){    
$message .= "Pohjustus: {$_POST['pohjustus_kevytlevy_selection']}<br />";
}
if(isset($_POST['pohjustus_kennolevy_selection']) && $_POST['pohjustus_kennolevy_selection'] != '' ){
$message .= "Pohjustus: {$_POST['pohjustus_kennolevy_selection']}<br />";
}
if(isset($_POST['pohjustus_muu_selection']) && $_POST['pohjustus_muu_selection'] != '' ){
$message .= "Muu pohjustus: {$_POST['pohjustus_muu_selection']}<br />";
}
if(isset($_POST['kehys_u_profiili']) && $_POST['kehys_u_profiili'] != '' ){
$message .= "U-Profiilikehystys: {$_POST['kehys_u_profiili']}<br />";
}
if(isset($_POST['kehys_alumiini']) && $_POST['kehys_alumiini'] != '' ){
$message .= "Alumiinikehystys: {$_POST['kehys_alumiini']}<br />";
}
if(isset($_POST['listat']) && $_POST['listat'] != '' ){    
$message .= "Listat: {$_POST['listat']}<br />";
}
if(isset($_POST['RollUp-teline']) && $_POST['RollUp-teline'] != '' ){  
$message .= "Lis&auml;tarvikkeet/RollUp-teline: {$_POST['RollUp-teline']}<br />";
}
if(isset($_POST['rollup-teline_kpl']) && $_POST['rollup-teline_kpl'] != '' ){  
$message .= "Lis&auml;tarvikkeet/RollUp-teline/kappalem&auml;&auml;r&auml;: {$_POST['rollup-teline_kpl']}<br />";
}
if(isset($_POST['popup-teline']) && $_POST['popup-teline'] != '' ){
$message .= "Lis&auml;tarvikkeet/PollUp-teline: {$_POST['popup-teline']}<br />";
 }
if(isset($_POST['popup-teline_kpl']) && $_POST['popup-teline_kpl'] != '' ){
$message .= "Lis&auml;tarvikkeet/PollUp-teline/kappalem&auml;&auml;r&auml;: {$_POST['popup-teline_kpl']}<br />";
}
if(isset($_POST['R-type']) && $_POST['R-type'] != '' ){
$message .= "Lis&auml;tarvikkeet/R-type: {$_POST['R-type']}<br />";
}
if(isset($_POST['tuote_04_kpl']) && $_POST['tuote_04_kpl'] != '' ){
$message .= "Lis&auml;tarvikkeet/R-type/kappalem&auml;&auml;r&auml;: {$_POST['R-type_kpl']}<br />";
}

$message .= "Toimitustapa: {$_POST['Toimitustapa']}<br />";
     
      $message .= "Viesti: {$_POST['vapaateksti']}<br /><br />";

      $message .= "Yrityksen nimi: {$_POST['Yrityksen_nimi']}<br />";
      
$message .= "Tilaajan nimi: {$_POST['Tilaajan_nimi']}<br />";

      $message .= "S&auml;hk&ouml;posti: {$_POST['Sahkoposti']}<br />";

      
      $message .= "Puhelin: {$_POST['Puhelin']}<br />";
      
      $message .= "Tilaajan osoitetiedot: {$_POST['Yhteystiedot']}<br />";

   
    $subject = "Tarjouspyynto PrintStudion www-sivuilta";

include("class.phpmailer.php");

$mail = new PHPMailer();
$mail->From = "www.testi.fi";
$mail->FromName = "Tarjouspyyntolomake";
$mail->AddAddress("test@mail.be");
// $mail->AddAddress("$_POST['palautteenvastaanottaja']");

$mail->AddAttachment($_FILES['tiedosto1']['tmp_name'], basename($_FILES['tiedosto1']['name'])); // liitetiedosto 1
$mail->AddAttachment($_FILES['tiedosto2']['tmp_name'], basename($_FILES['tiedosto2']['name'])); // liitetiedosto 2
$mail->AddAttachment($_FILES['tiedosto3']['tmp_name'], basename($_FILES['tiedosto3']['name'])); // liitetiedosto 3
$mail->IsHTML(True);                               // viesti html, anna olla oletuksena.

$mail->Subject  =  $subject; //
$mail->Body     =  $message;
if(!$mail->Send())
{
   echo "Tarjouspyynt&ouml;si ei l&auml;hetetty <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
} else {
   echo "Tarjouspyynt&ouml;si on l&auml;hetetty";
   echo "<br><br>";
   echo "Sinut ohjataan Printstudion etusivulle";  
}

?>
</body>
</html>
0
 

Author Comment

by:tikkanen
ID: 18856849
Our email services have problems. That's reason why I get error messages. I change smtp address and now it works. Routinet get points instead.
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 18862195
>>> Failed to connect to mailserver at "mail.eunet.fi" port 25,

At least it was something simple, yes?  :)  Good luck!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question