Solved

Mailer Error: Could not instantiate mail function.

Posted on 2007-04-04
6
2,888 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:tikkanen
Comment Utility
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
Comment Utility
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
Comment Utility
>>> Failed to connect to mailserver at "mail.eunet.fi" port 25,

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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now