Forum Moderators: mack

Message Too Old, No Replies

setting up smtp with php mailer on localhost

for newbies like me

         

phlogit

9:43 am on May 20, 2007 (gmt 0)

10+ Year Member



Hi,

Because it took me so long (whole day) to figure out, i would like to post my problem and solution on the forum to prevent a waste of time for other newbies such as myself.

Problem - my problem was that when a new user registered his/her details they never used to get a confirmation/activation email even though the details where stored in the userdata sql table. This prevented them from using the username again and stopped them from logging in.

P.S. This problem was encountered on my localhost as i wanted to make sure the software/code was fully functional before making the necessary changes and going live.

Solution - Firstly you need to install an smtp server on your computer if you dont all ready have on. You can do this at the following website.
www.softstack.com/freesmtp.html
You then need to make some changes to your php.ini file which should be located in your WINDOWS directory. Search for SMTP and you should find

[mail function]
; For Win32 only.
SMTP = smtp.myisp.co.uk

you need to replace "smtp.myisp.co.uk" with your own ISP (Internet Service Provider) Server.

In the same file you need to search for sendmail and you should come up with(it is directly below the smtp section)

; For Win32 only.
sendmail_from = myname@myisp.co.uk

This is where you put your email address given to you by your ISP.
(you then need to restart your computer to make sure the changes have taken effect).

you then need to go to the directory where the code/software is and look for class.phpmailer.php and find and change the following:

/**
* Method to send mail: ("mail", "sendmail", or "smtp").
* @access public
* @var string
*/
var $Mailer = "mail";

change the mail to smtp like this:

/**
* Method to send mail: ("mail", "sendmail", or "smtp").
* @access public
* @var string
*/
var $Mailer = "smtp";

Once you hve done this put the smtp server name (provided by isp which you used in php.ini earlier) here:

/**
* Sets the SMTP hosts. All hosts must be separated by a
* semicolon. You can also specify a different port
* for each host by using this format: [hostname:port]
* (e.g. "smtp1.example.com:25;smtp2.example.com").
* Hosts will be tried in order.
* @access public
* @var string
*/
var $Host = "smtp.myisp.co.uk";


you then need to download the following phpmailer from the following site

[sourceforge.net...]

Once you have downloaded and extracted the zip file copy and paste the "class.smtp.php" file into your software/code directory. So the "class.smtp.php" file should be in the same directory as the "class.phpmailer.php" file.

You should now be able use the member registration and activation from your home computer on localhost.

If anyone thinks i have done something wrong or unnecessary. Then please post here to help me and others. Any shortcuts or help please post.

If you have any further problems in regards to this issue please post here and i will do my best to help and save you time.

mack

7:43 am on May 21, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Thanks for the post, and for sharing your solution. I am sure this will help a lot of users out who are experiencing problems. One word of caution to anyone who installs an SMTP server on your PC is to make sure you read any documentation that comes with it. It "can" leave you with an open mail script running on your system, obviously the security risk is not great, but it is there never the less.

Again thanks for sharing your experience.

Mack.