CodeIgniter Forums

Full Version: Email library : mail() function issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2

El Forum

[eluser]metalking[/eluser]
Hi everybody!

I'm just trying to build a mail module for my application (some kind of newsletter), and I'm having some problems with the Email library.

When I try to send a mail using the method described in the user guide, I get a PHP warning, saying that in libraries/Email.php, at line 1232, the mail() function receives a wrong number of parameters.

My CI code :

Code:
$this->load->library('email');

$emailconfig['protocol'] = 'smtp';
$emailconfig['smtp_host'] = 'smtp.gmail.com';
$emailconfig['smtp_user'] = 'username';
$emailconfig['smtp_pass'] = 'password';
$emailconfig['smtp_port'] = '465';

$this->email->initialize($emailconfig);

$this->emails = $this->get_emails($this->validation->destinataires);
foreach($this->emails as $email)
{
$this->email->from('[email protected]', 'The Polygon\'s Battle');
$this->email->reply_to('[email protected]', 'metalking');
$this->email->to($email['email']);

$this->email->subject($this->validation->sujet);
$this->email->message($this->validation->message);

if($this->email->send())
{}
else
$this->mailerror = 1;
                    
$this->email->clear();
}

Don't care about vars names and so on, the only error I get (at the moment) is this PHP error, which says CI sends a wrong number of parameters to the mail() function.

Have you any idea of what the problem is?


Thanks ! Wink

El Forum

[eluser]optimal[/eluser]
Hello,

Have you verified that all the necessary parameters have values? I notice a reference above to "sujet." Is that correct?

El Forum

[eluser]metalking[/eluser]
Yeah, I'm just a frenchie ^^

"Sujet" means "Subject", and is defined by form (validated by the validation class, so it is not empty).
I'm pretty sure all parameters have values...

Any idea?

El Forum

[eluser]sophistry[/eluser]
pretty sure? make sure. then ask.

El Forum

[eluser]metalking[/eluser]
It's OK, I'm sure all params have values (verified with echo's of my values).

Any idea?

El Forum

[eluser]sophistry[/eluser]
you have to echo the params at the point of the error if you want to fix it. have you done that? i'd be surprised if the PHP parser complained about missing parameters if there were no missing parameters. that is, check the parameter values exactly where the error is thrown.

El Forum

[eluser]metalking[/eluser]
Hi!

This problem is OK now (I really don't know how, but the mail() error is solved).

However, I have new PHP warnings :

Quote:A PHP Error was encountered
Severity: Warning
Message: fwrite(): supplied argument is not a valid stream resource
Filename: libraries/Email.php
Line Number: 1481

And

Quote:A PHP Error was encountered
Severity: Warning
Message: fgets(): supplied argument is not a valid stream resource
Filename: libraries/Email.php
Line Number: 1502

It seems to be about SMTP (looking in the Email.php). Is there something particular with Gmail?
I know it needs a SSL connexion, but don't know how to set it (appart from the port, that must be 465).

Does someone know how to send SMTP mails with Gmail?

Thanks !

El Forum

[eluser]sophistry[/eluser]
did you search the forums?

El Forum

[eluser]metalking[/eluser]
With no success...

El Forum

[eluser]optimal[/eluser]
I haven't done this but would like to for testing purposes. From some reading it appears you may need to install OpenSSL, and (re)compile PHP with OpenSSL support.

Some links I found:

http://www.codingforums.com/showthread.php?p=576443
http://us.php.net/openssl
http://drupal.org/node/132888

If this is true, it sounds like quite the little afternoon project . . .
Pages: 1 2