简体   繁体   中英

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 ie

in php.ini

; For Win32 only.
SMTP = smtp.gmail.com
smtp_port = 465
; For Win32 only.
;sendmail_from = myemail@gmail.com
sendmail_path ="C:\wamp\sendmail\sendmail.exe -t" 

And in sendmail.ini

smtp_server=smtp.gmail.com
smtp_port=465
auth_username=myemail@gmail.com
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.

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 :)

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', 'ValidEmailAccount@YourDomain.com');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM