TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-05-2008, 01:53 PM   #1 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default Mail function..

Hi!

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

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..
__________________
Tanax is offline  
Reply With Quote
Old 05-05-2008, 03:09 PM   #2 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

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.
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 05-05-2008, 03:13 PM   #3 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by Orc View Post
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
__________________
Tanax is offline  
Reply With Quote
Old 05-05-2008, 03:15 PM   #4 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
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

?>
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 05-05-2008, 03:26 PM   #5 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by Orc View Post
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? ;<
__________________
Tanax is offline  
Reply With Quote
Old 05-05-2008, 03:28 PM   #6 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
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.
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 05-05-2008, 04:08 PM   #7 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

What do I need to set that up? xDD hhaha, sorry for basic questions :O
__________________
Tanax is offline  
Reply With Quote
Old 05-05-2008, 05:59 PM   #8 (permalink)
The Acquainted
 
freenity's Avatar
 
Join Date: Feb 2008
Posts: 119
Thanks: 17
freenity is on a distinguished road
Default

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....
__________________
http://feudal-times.net - My PBB Game
http://gwphp.feudal-times.net - My Blog "Gaming With PHP"
freenity is offline  
Reply With Quote
Old 05-05-2008, 08:20 PM   #9 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

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
delayedinsanity is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 08:27 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design