TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   Mail function.. (http://www.talkphp.com/advanced-php-programming/2760-mail-function.html)

Tanax 05-05-2008 01:53 PM

Mail function..
 
Hi!

I'm having some trouble with my mail function.
Or well.. erh.. just look :-P

php Code:
/**
        * @ Sends an activation email to the newly registered user
        *
        * @ Returns true or false
        **/

        private function sendActMail() {
           
            $sql = sprintf("    SELECT
                                    *
                                FROM
                                    `%s`"
,
                                   
                                $this->db->table['config']);
                               
            $query = $this->db->query($sql) or die(mysql_error());
            if($query) {
               
                $config = $this->db->fetch($query);
               
                $to = $this->reg_userinfo['email'];
                $subject = $config['actMail_subject'];
               
                    $subjectdata = array(
                   
                        'username' => $this->reg_userinfo['uname'],
                        'website' => $config['website_name']
                   
                    );
                   
                    $subject = $this->tpl->getParsed($subjectdata, $subject);
               
               
                $message = $config['actMail_message'];
               
                    $messagedata = array(
                   
                        'username' => $this->reg_userinfo['uname'],
                        'password' => $this->reg_userinfo['pword'],
                        'activationcode' => $this->reg_userinfo['actCode'],
                        'email' => $config['website_email'],
                   
                    );
                   
                    $message = $this->tpl->getParsed($messagedata, $message);
                   
                $headers = 'From: ' . $config['website_email'];
               
                $mail = mail($to, $subject, $message, $headers);
               
                if($mail) {
                   
                    return true;
                   
                }
               
                return false;
               
            }
           
            return false;
           
        }

gives me this..

Code:

Warning: 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() in C:\..user.php on line 358
I know this means that you can't send a mail from localhost..
but does the email function work other than that? Cause I can't test it.. since I don't have an smtp server..

Orc 05-05-2008 03:09 PM

yes it does work, this means you have no smtp server for it to actually transfer the email. but like the error said, you can set it in the ini or use the ini_set function.

Tanax 05-05-2008 03:13 PM

Quote:

Originally Posted by Orc (Post 14309)
yes it does work, this means you have no smtp server for it to actually transfer the email. but like the error said, you can set it in the ini or use the ini_set function.

And how do I set it? :O

Orc 05-05-2008 03:15 PM

Quote:

Originally Posted by Tanax (Post 14310)
And how do I set it? :O

PHP Code:


<?php

ini_set
("SMTP""THE_SMTP_SERVER_HERE"); // usually an ip with a connection to it
ini_set("smtp_port",80); // set the port

?>


Tanax 05-05-2008 03:26 PM

Quote:

Originally Posted by Orc (Post 14311)
PHP Code:


<?php

ini_set
("SMTP""THE_SMTP_SERVER_HERE"); // usually an ip with a connection to it
ini_set("smtp_port",80); // set the port

?>


How do I know the smtp server? ;<

Orc 05-05-2008 03:28 PM

Quote:

Originally Posted by Tanax (Post 14312)
How do I know the smtp server? ;<

You need to set one up, you can set one up on your localhost, with a different port, like so:

localhost:6065 as the port for the smtp
or 127.0.0.1:6065 or whatever.

Tanax 05-05-2008 04:08 PM

What do I need to set that up? xDD hhaha, sorry for basic questions :O

freenity 05-05-2008 05:59 PM

how to set up smtp server - Buscar con Google
;)

stmp server is like apache or mysql server. This mean that it also has an open port and do stuff....

delayedinsanity 05-05-2008 08:20 PM

You may not need to set one up, if your ISP provides you with a POP3 email address, chances are they have an outgoing SMTP server that you can use. Look up your ISP's website, or contact their tech support, and look up information regarding 'setting up your email'. Find out the address of their SMTP, usually mail.yourisp.com, and then you just need to add this into your PHP.INI file, and wala. Much easier than setting up sendmail or some equivalent.
-m


All times are GMT. The time now is 03:45 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0