This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Day 12: "Could not instantiate mail function" Error

Discussion around this tutorial for symfony 1.0.x

Day 12: "Could not instantiate mail function" Error

by hsteckylf » Wed Jun 14, 2006 10:43 pm

I am working with version 0.7.1369.

I went through the entirety of day 12 with the email setup for lost passwords. My problem is that I keep getting the "Could not instantiate mail function" error. I have gone through all of the svn's trying to see if I missed anything, but it appears I have all of the files required.

I am running this on my own apache server and am lost. Any help would be GREATLY appreciated.

And yes, I have cleared the cache.
hsteckylf
Member
 
Posts: 75
Joined: Fri May 05, 2006 4:06 am
Location: MD

Re: Day 12: "Could not instantiate mail function" Error

by francois » Fri Jun 16, 2006 6:21 pm

This was fixed in a later version. Upgrade your symfony files, clear the cache, and all should work fine.
francois
Faithful Member
 
Posts: 1638
Joined: Sat Oct 22, 2005 4:56 pm

Re: Day 12: "Could not instantiate mail function" Error

by hsteckylf » Fri Jun 16, 2006 6:42 pm

Code: Select all
***@***:~$ sudo symfony -V
symfony version 0.7.1369
***@***:~$ sudo pear upgrade symfony/symfony-beta
downloading symfony-0.7.1456.tgz ...
Starting to download symfony-0.7.1456.tgz (1,270,162 bytes)
............................................................................................................................................................................................................................................................done: 1,270,162 bytes
ERROR: pear.symfony-project.com/symfony not installed

is there something I am missing?
hsteckylf
Member
 
Posts: 75
Joined: Fri May 05, 2006 4:06 am
Location: MD

Re: Day 12: "Could not instantiate mail function" Error

by francois » Fri Jun 16, 2006 7:01 pm

your pear config is probably messed up. Type pear config-show and check if some directory parameters point to the wrong place.
francois
Faithful Member
 
Posts: 1638
Joined: Sat Oct 22, 2005 4:56 pm

Re: Day 12: "Could not instantiate mail function" Error

by hsteckylf » Fri Jun 16, 2006 7:42 pm

I am not sure what caused it, but the results of pear config-show were similar to what happened at http://www.symfony-project.com/trac/ticket/443 and that resolution worked for me.

However, even after fixing this, then upgrading to version 0.7.1456 and clearing the cache on my app, I am still getting the "Could not instantiate mail function" error.

Any other ideas or is there something I can post that would help you help me?
hsteckylf
Member
 
Posts: 75
Joined: Fri May 05, 2006 4:06 am
Location: MD

Re: Day 12: "Could not instantiate mail function" Error

by OutsideOfDreams » Mon Jun 26, 2006 7:29 pm

I'm getting the same error, and I've upgraded to the latest symfony beta (0.7.1505). I'm using XAMPP 1.53 on windows. Here is the fully symfony exception dump (moved to text file).
OutsideOfDreams
Junior Member
 
Posts: 13
Joined: Tue Apr 18, 2006 2:23 am

Re: Day 12: "Could not instantiate mail function" Error

by OutsideOfDreams » Mon Jun 26, 2006 8:43 pm

Ok, I can proceed without getting the "Could not instantiate mail function" error in dev mode. However, in production, I get a blank page after submitting the form. Here is my new code taking from Day 12 and "How to send an email" from the documentation:

Code: Select all
public function executeSendPassword()
{
  $mail = new sfMail();
 
  $mail->initialize();
  $mail->setMailer('sendmail');
  $mail->setCharset('utf-8');

  $mail->addAddress($this->getRequestParameter('email'));

  $cFrom = sfConfig::get('app_detail_email');
  $cAppName = sfConfig::get('app_detail_name');
 
  $mail->setSender($cFrom, $cAppName);
  $mail->setFrom($cFrom, $cAppName);
  $mail->addReplyTo($cFrom);
  $mail->setSubject($cAppName.' password recovery');
 
  $mail->setPriority(1);
 
  $mail->addEmbeddedImage(sfConfig::get('sf_web_dir').'/images/askeet_logo.gif', 'CID1', $cAppName.' Logo', 'base64', 'image/gif');
 
  $this->nickname = $this->getRequest()->getAttribute('nickname');
  $this->password = $this->getRequest()->getAttribute('password');

  $this->mail = $mail;
}


These are the lines that got me past the error:
Code: Select all
$mail->initialize();
$mail->setMailer('sendmail');


Looks like the mailer.yml config file isn't getting read for the mailer: sendmail config value.

Problem is that I don't receive the e-mail (in dev or production), that may be in my config files somewhere. I'm using XAMPP, so if anybody could point me to where I can set my smtp server...
OutsideOfDreams
Junior Member
 
Posts: 13
Joined: Tue Apr 18, 2006 2:23 am

Re: Day 12: "Could not instantiate mail function" Error

by hsteckylf » Thu Jun 29, 2006 3:43 pm

so what I'm understanding is that no one has an answer on how to fix this problem and have the emails sent out? Grr... :?~ :-?~ :???:
hsteckylf
Member
 
Posts: 75
Joined: Fri May 05, 2006 4:06 am
Location: MD

Re: Day 12: "Could not instantiate mail function" Error

by zsolesz » Tue Jul 11, 2006 3:00 pm

So what was the latest solution for this

"Could not instantiate mail function."

problem?

ty
zsolesz
Senior Member
 
Posts: 126
Joined: Wed Jul 05, 2006 9:58 pm
Location: Budapest, Hungary

Re: Day 12: "Could not instantiate mail function" Error

by hsteckylf » Tue Jul 11, 2006 3:47 pm

none... I have tried the few things mentioned above and I can still not get mail to be sent. :(~ :-(~ :sad:
hsteckylf
Member
 
Posts: 75
Joined: Fri May 05, 2006 4:06 am
Location: MD

Re: Day 12: "Could not instantiate mail function" Error

by zsolesz » Tue Jul 11, 2006 4:02 pm

i'm trying to configure

class.phpmailer.php
php.ini
class.smtp.php

so,

http://manual.mantisbt.org/manual.configuration.email.php

on this page i found some interesting infos, but i can't find that

'config_inc.php' file, where they are manipulating this

$g_phpMailer_method = 2;

$g_smtp_host = '_host_';
$g_smtp_username = '_user_name_';
$g_smtp_password = '_password_';

thinnngs.
---
OK!

now that config_inc.php doesnt matter.

its important to change the mailer to 'smtp' in the mailer.yml,

and i changed php.ini:

For Win32 only.
sendmail_from = [url=mailto:ab@cd.e]ab@cd.e[/url]

and

uncommented those lines:
extension=php_smtp.dll
extension=php_mailparse.dll

guess that the last two modifications were the most important ones.

hope that i helped
zsolesz
Senior Member
 
Posts: 126
Joined: Wed Jul 05, 2006 9:58 pm
Location: Budapest, Hungary

Re: Day 12: "Could not instantiate mail function" Error

by itsjawad » Wed Oct 17, 2007 4:04 pm

hi guys,
I followed the askeet tutorial for the email sending at here:
http://www.symfony-project.com/askeet/1_0/12

I exactly followed the tutorial and applied the settings in php.ini as shown above but the email is not actually sent. but it shows the success template.

I tried normal php mail function, it is working fine.. so it means that my smtp php.ini settings are correct.. anything is missing while using sfMail with symfony..!

any ideas!!
itsjawad
Junior Member
 
Posts: 13
Joined: Tue Jul 31, 2007 2:09 pm

Re: Day 12: "Could not instantiate mail function" Error

by Bart » Sun Dec 09, 2007 2:05 am

if you trace the code on the tutorial carefully, you'll notice this:

Quote: wrote:
public function executePasswordRequest()
{
...
$raw_email = $this->sendEmail('mail', 'sendPassword');
....

AND
mailer.yml
Quote: wrote:
dev:
deliver: off

all:
mailer: sendmail

AND
Quote: wrote:
This stipulates the mailer program to be used to send mails, and deactivates the sending of mails in the development environment - the emails in the test data are fake anyway.


You should be able to figure out what's wrong :D~ :-D~ :grin:

I like to think these 'errors' are there on purpose, so you are forced to think for yourself... And thus achieving a better understanding of symfony... Great job guys!
Bart
Member
 
Posts: 33
Joined: Sun Dec 09, 2007 1:55 am
Location: Belgium

Re: Day 12: "Could not instantiate mail function" Error

by Bart » Sun Dec 09, 2007 2:09 am

By the way these changes did the trick for me
Code: Select all
dev:
  deliver:    off

all:
  mailer:     sendemail
Bart
Member
 
Posts: 33
Joined: Sun Dec 09, 2007 1:55 am
Location: Belgium

Re: Day 12: "Could not instantiate mail function" Error

by jamsoft » Tue Oct 07, 2008 3:07 pm

I had the same problem.
I use wamp, sf 1.1.
I dont use mailer.yml, because as I searched our site there are still many problems (I encountered them).

So I didnt change any config files(php.ini) only used sendmail instead of mail.
// class initialization
$mail = new sfMail();
$mail->initialize();
$mail->setMailer('sendmail');
$mail->setCharset('utf-8');
//my activities
$mail->send();
Previosly I used $mail->setMailer('mail');
and when not correct emails given I had that problem (error msg). Correct where delivered.
Now sendmail is not sensible to incorrect emails.

cheers
rest break is good - for many problems - espacially programming
jamsoft
Junior Member
 
Posts: 21
Joined: Wed Aug 20, 2008 1:19 am
Location: Poland