Page 1 of 1

Connecting to smtp host

Posted: Tue Mar 08, 2005 11:28 am
by drdan
Hi,

I am in need of help in making a connection to the smtp server so I can send out email with my php code rather than using the mail() function.

I have a smtp class that handles the php code. I don't think I understand how smtp hosts work. I know I have three different hosts available to me but I can't connect to any of them. Are there restrictions to working with these smtp hosts?

The code I am using have the following parameters.

Code: Select all

<?php
	function setSMTPParams($host = null, $port = null, $helo = null, $auth = null, $user = null, $pass = null)
	{
		if (!is_null($host)) $this->smtp_params['host'] = $host;
		if (!is_null($port)) $this->smtp_params['port'] = $port;
		if (!is_null($helo)) $this->smtp_params['helo'] = $helo;
		if (!is_null($auth)) $this->smtp_params['auth'] = $auth;
		if (!is_null($user)) $this->smtp_params['user'] = $user;
		if (!is_null($pass)) $this->smtp_params['pass'] = $pass;
	}
?>


I understand the following:

$host = something like smtp1.hostname.com. There are a lot of examples where localhost is said to be able to work. What conditions would allow localhost to work since it doesn't work for me?

$port = seems to always be 25. Is that true?

$helo I just don't understand what that is for.

$auth seems to be a TRUE or FALSE statement indicating whether a user name or password is required. How do I know if that is required or not?

$user and $pass are the user name and password and I am assuming these are the same values give to me by my ISP who runs the smtp in question.

Well, that is as much as I know. If anyone can help me to see this more clearly or let me know what limitations I might be up against that would be much appreciated.

Thanks

Dan

Re: Connecting to smtp host

Posted: Tue Mar 08, 2005 11:15 pm
by Buddha443556
drdan wrote:$host = something like smtp1.hostname.com. There are a lot of examples where localhost is said to be able to work. What conditions would allow localhost to work since it doesn't work for me?
You would use localhost if you had a mail server running locally, like Mercury Mail Server.
drdan wrote:$port = seems to always be 25. Is that true?
gmail doesn't use port 25. Email over SSL may also not use port 25 either. It depends on your email account.
drdan wrote:$helo I just don't understand what that is for.
I normal use something like my domain name: mail.mydomain.com
Don't leave it blank some servers don't like that.
drdan wrote:$auth seems to be a TRUE or FALSE statement indicating whether a user name or password is required. How do I know if that is required or not?
Again depends on your email account. Should almost always be TRUE even when running a local mail server.
drdan wrote:$user and $pass are the user name and password and I am assuming these are the same values give to me by my ISP who runs the smtp in question.
Yes.

Hope that helps.