not able to send email |
[eluser]bevans[/eluser]
I get the following error when trying to send an email using the Email Class: A PHP Error was encountered Severity: Warning Message: mail() expects parameter 1 to be string, array given Filename: libraries/Email.php Line Number: 1341 Here are some details: I am not using an array, I only pass one email address to the "to" field. There is no cc or bcc. Here is the controllers info: Code: $this->load->library('email'); What am I doing wrong, and how do I fix it? Thanks in advance.
[eluser]Michael Wales[/eluser]
Can you print_r the $_POST['email'] variable and let us know what it returns.
[eluser]bevans[/eluser]
[quote author="Michael Wales" date="1204599584"]Can you print_r the $_POST['email'] variable and let us know what it returns.[/quote] Yes, When I use print_r($_POST['email']); It prints out the email address I enter in the form. In this case, I just used a dummy email address of "[email protected]" then when I click submit on the form. I get the email printed on the top of the screen just like it is: [email protected] So the email address that gets passed to $_POST['email'] is the correct email. Here is some background that I should have given sooner. I have a registration form that people need to enter their name, email, username, and password. When they submit the form, I want to have CI send them an email stating that they have successfully registered. The error that I get occurs when the form is submitted.
[eluser]Pygon[/eluser]
well.. if | echo $_POST['email']; | is giving you the email address, you might try using a hardcoded email being passed to the $this->email->to() and see what happens.
[eluser]bevans[/eluser]
[quote author="Pygon" date="1204600408"]well.. if | echo $_POST['email']; | is giving you the email address, you might try using a hardcoded email being passed to the $this->email->to() and see what happens.[/quote] I have used a hard-coded email in place of $_POST['email'], but it still gives me the same error. I am a little lost... is there a bug of some kind?
[eluser]Pygon[/eluser]
Actually -- looking at it, it may be: try this: applications/libraries/MY_Email.php Code: <?php Not positive it will work, but worth a shot. (I don't have mail on my local webserver) Drop it in and run the script again as is.
[eluser]bevans[/eluser]
When I try that class you gave Pygon, I get this error now: A PHP Error was encountered Severity: Warning Message: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing Filename: libraries/Email.php Line Number: 1341 The php.ini file is set up. Maybe something in it is wrong. Here is what my php.ini file says: [mail function] ; For Win32 only. ;This is the original setting >>> SMTP = localhost ; the following two lines are added for the godbit.com tutorial ; changed SMTP to: SMTP = localhost as indicated above, but it does not make a difference SMTP = mail.yahoo.com sendmail_from = bevans@yahoo.com smtp_port = 25 ; For Win32 only. ;sendmail_from = [email protected] ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ;sendmail_path = "D:\XAMPP\sendmail\sendmail.exe -t" ; Force the addition of the specified parameters to be passed as extra parameters ; to the sendmail binary. These parameters will always replace the value of ; the 5th parameter to mail(), even in safe mode. ;mail.force_extra_parameters =
[eluser]mikeyhell[/eluser]
Can you send a simple mail? Code: mail('[email protected]', 'My Subject', 'testing');
[eluser]bevans[/eluser]
[quote author="mikeyhell" date="1204618450"]Can you send a simple mail? Code: mail('[email protected]', 'My Subject', 'testing'); Negative. I cannot send a simple email using the mail() function. It gives me an error that the php.ini file is not set up correctly. (see below) I am beginning to think that it might be something with my local settings / machine, since I am still developing on my local machine. Error message (same as above error I listed in posting #6): A PHP Error was encountered Severity: Warning Message: mail() [function.mail]: “sendmail_from” not set in php.ini or custom “From:” header missing Filename: libraries/Email.php Line Number: 1341 When I run a phpinfo(); function, I get this: sendmail_from no value no value sendmail_path no value no value serialize_precision 100 100 short_open_tag On On SMTP localhost localhost smtp_port 25 25
[eluser]Pygon[/eluser]
TBH, It seems that you're making php.ini file changes to the php.ini that is not being loaded (or the webserver has not been restarted since the change). Regarding your first error, however, it seems that this might be a bug in CI, so i'll go ahead an post it for verification. |
Welcome Guest, Not a member yet? Register Sign In |