CodeIgniter Forums
Doesn't send SMTP email on localhost - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Doesn't send SMTP email on localhost (/showthread.php?tid=59854)



Doesn't send SMTP email on localhost - El Forum - 11-29-2013

[eluser]jatin.soni[/eluser]
Hello,

I am very new to CI and having trouble sending an email on localhost via SMTP. I have tried all possible things found on support and internet but none of them working at all.

System showing Sent Message but email never received. Tried own domain and gmail with no luck.

Any idea?


Doesn't send SMTP email on localhost - El Forum - 12-02-2013

[eluser]boltsabre[/eluser]
Got some code to show us? You're mail config stuff would help.
Have you tried debugging to isolate where exactly it is failing?


Doesn't send SMTP email on localhost - El Forum - 12-02-2013

[eluser]jatin.soni[/eluser]
[quote author="boltsabre" date="1385974053"]Got some code to show us? You're mail config stuff would help.
Have you tried debugging to isolate where exactly it is failing?[/quote]

I have tried more than 10-20 types of solution found on the board and on the net..like personal blogs and stackoverflow. None of them working at all..

Code:
function index()
{

  
  $config['protocol'] = 'smtp';
  $config['smtp_host'] = 'smtp.mydomain.com';
  $config['smtp_port'] = 25;
  $config['smtp_user'] = 'email.mydomain.com';
  $config['smtp_pass'] = 'mypassword';


  $this->load->library('email', $config);
  $this->email->set_newline("\r\n");
  
  $this->email->from('email.mydomain.com', 'Jatin Soni');
  $this->email->to('[email protected]');  
  $this->email->subject('This is an email test');  
  $this->email->message('It is working. Great!');
  
  
  if($this->email->send())
  {
   echo 'Your email was sent, successfully.';
  }
  
  else
  {
   show_error($this->email->print_debugger());
  }
}

I am really getting tired with this.. I spend more than 2 days to just get this email things works.. my entire system is based on notification and before I proceed to the system development. Email is very much important to test through development process...

Quote:At the moment I am feeling that writing own code is better than adopting any framework. It is high risk to be dependent for the professional project.



Doesn't send SMTP email on localhost - El Forum - 12-02-2013

[eluser]Massaki[/eluser]
Does it show any error message?
Maybe your firewall blocks port 25.


Doesn't send SMTP email on localhost - El Forum - 12-02-2013

[eluser]CroNiX[/eluser]
If "localhost" is on your home network, then Massaki probably has the correct answer and your host likely blocks port 25. Most do. If you are on windows, there is a easy solution called "smtp4dev" if you google it. It's a small app that intercepts outgoing mail on port 25 and shows it to you in your email client so you can test even if port 25 is blocked.

I'd check this to see if it's blocked by your ISP:
https://kb.mediatemple.net/questions/888/Checking+your+outgoing+mail+server+(Is+Port+25+blocked?)


Doesn't send SMTP email on localhost - El Forum - 12-02-2013

[eluser]jatin.soni[/eluser]
[quote author="Massaki" date="1385997320"]Does it show any error message?
Maybe your firewall blocks port 25.[/quote]

It is not showing any error and throwing "Mail sent successfully!" message. It's weird ...


Doesn't send SMTP email on localhost - El Forum - 12-02-2013

[eluser]jatin.soni[/eluser]
[quote author="CroNiX" date="1386003310"]If "localhost" is on your home network, then Massaki probably has the correct answer and your host likely blocks port 25. Most do. If you are on windows, there is a easy solution called "smtp4dev" if you google it. It's a small app that intercepts outgoing mail on port 25 and shows it to you in your email client so you can test even if port 25 is blocked.

I'd check this to see if it's blocked by your ISP:
https://kb.mediatemple.net/questions/888/Checking+your+outgoing+mail+server+(Is+Port+25+blocked?)[/quote]

I got two machines ..XAMPP for older machine has been installed few years ago and modified by the time as per my need. I haven't edited so much things in XAMPP installed on the new machine.

When I tried to send email from fresh CI installed from older machine than just wonder things goes well without any problem just like charm.. I can receive email without issue.

So now this is another frustration to find what issue exactly happen to this machine or XAMPP settings or some compatibility issue etc..

Can new version of XAMPP can create an issue? Is there any issue with authentication with XAMPP? Since I am authenticating to access XAMPP??


Doesn't send SMTP email on localhost - El Forum - 12-03-2013

[eluser]boltsabre[/eluser]
>> When I tried to send email from fresh CI installed from older machine
Well I'd try it on your new XAMPP with a completely fresh install of CI (just like you did on your old one) and see it that works.
At least this will let you know if it's something with your current code or something else.

I feel for you, I have also spend days on end trying to get email working locally / XAMPP, it's a real pain!!!