bkashaf
bkashaf

Reputation: 136

sending email to gmail in php codeigniter

I have to send email to gamil for registration of account in my website. I am using wamp ,win 7, codeigniter. And sending mail through sendmail. I have made all required changes i.e

in php.ini

; For Win32 only.
SMTP = smtp.gmail.com
smtp_port = 465
; For Win32 only.
;sendmail_from = [email protected]
sendmail_path ="C:\wamp\sendmail\sendmail.exe -t" 

And in sendmail.ini

smtp_server=smtp.gmail.com
smtp_port=465
[email protected]
auth_password=mypassword

But it shows this error instead of sending email.

Message: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() Filename: libraries/Email.php

It is still giving error on port 25 but i am using port 465. What could be the possible reason of this? What I am doing wrong? Any help.

Upvotes: 2

Views: 2475

Answers (2)

bkashaf
bkashaf

Reputation: 136

I just made those changes in C:\wamp\bin\apache\apache2.2.22\bin\php.ini instead of C:\wamp\bin\php\php.ini. And it works :)

Upvotes: 1

Daniel
Daniel

Reputation: 18682

I think you have to restart your server.

edit I found this thread with soulution:

Add the following code to the top of your email script if your mail script continues to fail.


// Please specify your Mail Server - Example: mail.yourdomain.com.
ini_set("SMTP","mail.YourDomain.com");

// Please specify an SMTP Number 25 and 8889 are valid SMTP Ports.
ini_set("smtp_port","25");

// Please specify the return address to use
ini_set('sendmail_from', '[email protected]');

Upvotes: 1

Related Questions