Solved

Mailer Error: Could not instantiate mail function.

Posted on 2007-04-04
6
2,902 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

792 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