CodeIgniter Forums

Full Version: fsockopen problem with email class
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Unknown[/eluser]
I've only recently started using CodeIgniter, so apologies if this is a common problem or anything. I did try searching and found a few vaguely related topics, but none of them solved the issues I'm having.

I'm trying to send a simple email when a user fills out a contact form on my website, it all works perfectly when I'm working locally on my PC, but when I transfer the site to my web hosting I get this error when it's trying to send the email:

Code:
A PHP Error was encountered

Severity: Warning

Message: fsockopen() [function.fsockopen]: unable to connect to mail.mydomainname.com:25 (Connection timed out)

Filename: libraries/Email.php

Line Number: 1652

I assume this error is because my host disable fsockopen, so does anyone know an easy-ish fix for this?

Thanks

El Forum

[eluser]eluzyon[/eluser]
Actually, I'm also having the same thing happening, but randomly... sometimes it works perfectly, other times it does not!

Any ideas ?

Thanks!

El Forum

[eluser]mi6crazyheart[/eluser]
@Tiestarian
Can u show u'r controller code...

El Forum

[eluser]Unknown[/eluser]
I've sorted it now. I had the "smtp_host" in my email config file set to my domain (mail.domainname.com)... but for some reason the server didn't like that. Changed the smtp server address to localhost (in the mail config file) and it now works perfectly Smile

El Forum

[eluser]mi6crazyheart[/eluser]
Great...