Welcome Guest, Not a member yet? Register   Sign In
Using an SMTP server to send emails
#1

[eluser]KeyStroke[/eluser]
Hi,

I'm trying to get my application to send emails in its local development environment (which was installed using XAMPP).

I already have an SMTP server in my production server, so is there anyway I could use that directly instead of the local one (which is Mercury/32)?

I tried altering the settings in my email config file, but I got a bunch of errors when trying to send an emails, which started with these:
Quote:A PHP Error was encountered

Severity: Warning

Message: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: No such host is known.

Filename: libraries/Email.php

Line Number: 1646
A PHP Error was encountered

Severity: Warning

Message: fsockopen() [function.fsockopen]: unable to connect to smtp.mysite.com:25 (php_network_getaddresses: getaddrinfo failed: No such host is known. )

Filename: libraries/Email.php

Line Number: 1646
(I've replaced my actual site's name with mysite.com)

Any ideas?


Appreciate your help Smile
#2

[eluser]TheFuzzy0ne[/eluser]
Try mail.mysite.com instead. I found it worked for my development server.

Also, I'm assuming you have those domains setup?
#3

[eluser]brianw1975[/eluser]
if that fails, just use the IP address of the mail server - i have found that in dev environments that sys admins tend to let mail servers go unconfigured in the DNS servers.
#4

[eluser]jedd[/eluser]
Quote:Message: fsockopen() [function.fsockopen]: unable to connect to smtp.mysite.com:25 (php_network_getaddresses: getaddrinfo failed: No such host is known. )

Your DNS or hosts file is not configured properly - your server has no idea what those names resolve to. hosts is easier to update if you don't own the development box. Alternatively point it to an IP address. From memory RFC2822 lets you route to IP addresses (though some servers break spec and decline) if you wrap the IP address component of the address in square brackets.

You can check visibility at the commandline (on almost any OS) with:
Code:
$   telnet  smtp.mysite.com   25
#5

[eluser]KeyStroke[/eluser]
Thanks everyone Smile

I've upgraded the server (XAMPP), and now I'm running into a different issue. Now I get this single error instead:
Quote:A PHP Error was encountered

Severity: Warning

Message: mail() [function.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

Line Number: 1519
php.ini only has options for smtp server and port; nothing for authentication, so I can't see how this would be useful. And no matter what I put there, it still displays the same message!

I don't understand why my CodeIgniter options are being ignored. Here's my CI code (this time trying Gmail):
Code:
function send_email()
{
    $this->load->library('email');

    $config['smtp_host'] = 'ssl://smtp.gmail.com';
    $config['smtp_user'] = '[email protected]'; // not my actual email obviously
    $config['smtp_pass'] = 'mypassword';
    $config['smtp_port'] = 465;

    $this->email->initialize($config);
    $this->email->from('[email protected]', 'KeyStroke');
    $this->email->reply_to('[email protected]', 'KeyStroke');
    $this->email->to('[email protected]');
    $this->email->subject('Hello world!');
    $this->email->message('Testing emails.');
    $this->email->send();
}
(yes, OpenSSL is installed and working)

TheFuzzy0ne:
Yes, they are actually my domains hosted on my own VPS server.

brianw1957:
Doesn't work. Sad

---------------

What am I doing wrong here? Sad
#6

[eluser]KeyStroke[/eluser]
SOLVED !!!

I finally found very simple instructions on how to send emails from a local XAMPP installation. You can find it here:
http://i.justrealized.com/2008/05/02/how...-in-xampp/

Now emails works flawlessly. *wipes tears of joy*




Theme © iAndrew 2016 - Forum software by © MyBB