Solved

Mailer Error: Could not instantiate mail function.

Posted on 2007-04-04
6
2,912 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to count occurrences of each item in an array.
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.

733 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