sending email using code igniter |
I am trying to send email using code igniter and I am not having any luck. I am hosting on a go daddy server. Here is my code. Do I need to create another view? Could there be issues associated with the config file?
PHP Code: <?php
Did you just put your email password inside the code?
![]() Website: http://avenir.ro
Have you loaded the email library? And you should use your constructor like that:
PHP Code: parent::__construct(); (01-15-2015, 08:35 PM)Ben Wrote: I am trying to send email using code igniter and I am not having any luck. I am hosting on a go daddy server. Here is my code. Do I need to create another view? Could there be issues associated with the config file? Okay, first of all, you need to initialise the email class with the new config, not when loading the library: $this->email->initialize($config); And also you have // $this->email->send(); which sends the email commented out; remove the // and it should work.
01-16-2015, 08:43 AM
(This post was last modified: 01-16-2015, 09:20 AM by Rufnex. Edit Reason: Format code )
I updated the code with everyone's suggestions. Nothing seems any different. Do I need to create a view to "see" the result of the call to this controller? This is the URL to where this is hosted:
http://www.designtimedesignworks.com/ci/index.php/email . PHP Code: <?php
Try this
PHP Code: <?php
I tried your update. I'm not getting different results with what I have hosted on go daddy, but I got some interesting results when I tried to access the file in my mamp. I don't think I can send email from my mamp, which is why I was testing this on a web server. Should I look at any other files on the server?
This was the output from my mamp (if that has any relevance, I don't think my mamp is really capable of sending email): A PHP Error was encountered Severity: Warning Message: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/ci/application/config/config.php:1) Filename: core/Common.php Line Number: 440 An Error Was Encountered 220 mx.google.com ESMTP cl9sm1841955igb.0 - gsmtp hello: 250-mx.google.com at your service, [71.57.41.94] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 Failed to authenticate password. Error: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/bin/answ...swer=78754 cl9sm1841955igb.0 - gsmtp from: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answe...swer=14257 cl9sm1841955igb.0 - gsmtp The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answe...swer=14257 cl9sm1841955igb.0 - gsmtp to: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answe...swer=14257 cl9sm1841955igb.0 - gsmtp The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answe...swer=14257 cl9sm1841955igb.0 - gsmtp data: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answe...swer=14257 cl9sm1841955igb.0 - gsmtp The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answe...swer=14257 cl9sm1841955igb.0 - gsmtp 502 5.5.1 Unrecognized command. cl9sm1841955igb.0 - gsmtp The following SMTP error was encountered: 502 5.5.1 Unrecognized command. cl9sm1841955igb.0 - gsmtp Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method. 220 mx.google.com ESMTP fr4sm1835034igd.4 - gsmtp hello: 250-mx.google.com at your service, [71.57.41.94] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 Failed to authenticate password. Error: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/bin/answ...swer=78754 fr4sm1835034igd.4 - gsmtp from: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answe...swer=14257 fr4sm1835034igd.4 - gsmtp The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answe...swer=14257 fr4sm1835034igd.4 - gsmtp to: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answe...swer=14257 fr4sm1835034igd.4 - gsmtp The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answe...swer=14257 fr4sm1835034igd.4 - gsmtp data: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answe...swer=14257 fr4sm1835034igd.4 - gsmtp The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answe...swer=14257 fr4sm1835034igd.4 - gsmtp 502 5.5.1 Unrecognized command. fr4sm1835034igd.4 - gsmtp The following SMTP error was encountered: 502 5.5.1 Unrecognized command. fr4sm1835034igd.4 - gsmtp Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method. User-Agent: CodeIgniter Date: Fri, 16 Jan 2015 19:47:53 +0100 From: "Ben Abrams" <[email protected]> Return-Path: <[email protected]> To: [email protected] Subject: =?iso-8859-1?Q?This_is_an_email_test.?= Reply-To: "[email protected]" <[email protected]> X-Sender: [email protected] X-Mailer: CodeIgniter X-Priority: 3 (Normal) Message-ID: <[email protected]> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit It is working.
@Ben
If you are out of options, try this: http://forum.codeigniter.com/thread-28.html Very carefully read README.md, install, compare and re-check configuration and try.
The error tells you that you have the wrong credentials for your smtp login. check this.
|
Welcome Guest, Not a member yet? Register Sign In |