Sending Simple Email PHP

Discussion in 'PHP' started by rendra_mm2, Jul 16, 2009.

?

Why i can't receive ?

  1. Bad Script ?

    0 vote(s)
    0.0%
  2. Wrong Script ?

    0 vote(s)
    0.0%
  3. Other ...

    100.0%
  1. rendra_mm2

    rendra_mm2 New Member

    Joined:
    Jul 10, 2009
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Freelancer
    Home Page:
    http://rendramm2.wordpress.com
    please check these file ! i need help ! why i can't receive that email ? :nonod:
     
    Last edited by a moderator: Jul 16, 2009
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Attachment removed. Try putting the code inline so its easy for us to look and suggest
     
  3. rendra_mm2

    rendra_mm2 New Member

    Joined:
    Jul 10, 2009
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Freelancer
    Home Page:
    http://rendramm2.wordpress.com
    mail.php

    PHP:
    <?php
    include "generator.class.php";
    if (isset(
    $_POST['email']) && isset($_POST['submit'])){
        
    $gen->id(6);
        
    $gen->mail($_POST['email'],'http://'.$SERVER_NAME.'/mjk/sub/register.php?id='.$gen->id.'');
    }
    if(isset(
    $_POST['submit']) && empty($_POST['email'])){
        
    $gen->alert('Email jangan dikosongi');
    }
    ?>
    <div style="font-family:trebuchet ms;" >
    <div id="forms">Email Registrasi </div>
    <div id="biasa">
    <form name="mail" method="post" action="page.php?menu=mail">
      <table border="0" cellspacing="0" cellpadding="3">
        <tr>
          <td>Send email to</td>
          <td>:</td>
          <td><input type="text" name="email" size="30"/></td>
          <td align="center"><input name="submit" type="submit" value="Kirim" /></td>
        </tr>
    </table>
    </form>
    </div>
    </div>

    <hr>
    generator.class.php
    PHP:
    class generator extends MYSQL{
        function 
    mail ($receiver$url){
            require_once(
    "class.mail.php");
            
            
    $mail = new mailsend();
            
    $mail->to="".$receiver."";
            
    $mail->subject="Form Registrasi Subdomain";
            
    $mail->message="".$url." Klik link disamping untuk melanjutkan registrasi secara online";
            
    $mail->header='From: [email]subdin_pde@mojokertokab.go.id[/email]' "\r\n" .
                            
    'Reply-To:subdin_pde@mojokertokab.go.id' "\r\n" .
                            
                            
    'X-Mailer: PHP/' phpversion();
            
    $mail->send();
        }
    }

    <
    hr>
    class.mail.php
    PHP:
    <?php

    class mailsend {
        var 
    $to;
        var 
    $subject ;
        var 
    $message 
        var 
    $header ;
        function 
    send(){
        
    mail($this->to$this->subject$this->message$this->header);
        }
    }
    ?>
     
    Last edited by a moderator: Jul 16, 2009
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Why dont you try just this one line script

    PHP:
    mail('you@yourdomain.com''My Subject''My Message');
    And see if it works.

    If you are using your local computer you would need an SMTP server to relay the email
     
  5. rendra_mm2

    rendra_mm2 New Member

    Joined:
    Jul 10, 2009
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Freelancer
    Home Page:
    http://rendramm2.wordpress.com
    I've tried it ... until now ,,, im not receive my Test email,,, What's the problem ? :thinking:
     
  6. rendra_mm2

    rendra_mm2 New Member

    Joined:
    Jul 10, 2009
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Freelancer
    Home Page:
    http://rendramm2.wordpress.com
    I'm confuse ... Why ? Damn'
     
  7. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Where are you running that scripts ?
     
  8. rendra_mm2

    rendra_mm2 New Member

    Joined:
    Jul 10, 2009
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Freelancer
    Home Page:
    http://rendramm2.wordpress.com
  9. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    There could be 2 reasons then

    1. Emails are in your spam folder
    2. Else either the mail server is not running or it needs a username password before you can send an email.
     
  10. rendra_mm2

    rendra_mm2 New Member

    Joined:
    Jul 10, 2009
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Freelancer
    Home Page:
    http://rendramm2.wordpress.com
    Ooowwhhh,,,,, maybe mail server...

    So... can u help me ?
    Would u like to give me your success PHP Mail Script ... ??? Please ... :happy: :wacky:
     
  11. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    its same as the one I have give you earlier and there is nothing that needs to be changed apart from your email address and it should work.
     
  12. rendra_mm2

    rendra_mm2 New Member

    Joined:
    Jul 10, 2009
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Freelancer
    Home Page:
    http://rendramm2.wordpress.com
    But why ??? ... Please help me ... :cryin: :undecided :confused:
     
  13. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    If you do not have the needed infra to send email how can we help :D
     
  14. rendra_mm2

    rendra_mm2 New Member

    Joined:
    Jul 10, 2009
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Freelancer
    Home Page:
    http://rendramm2.wordpress.com
    Nothing yet ...

    Cause this is my problem ... I make an e-commerce,,, but i can't send an email ...
     
  15. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Ask your host to enable it.
     
  16. rendra_mm2

    rendra_mm2 New Member

    Joined:
    Jul 10, 2009
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Freelancer
    Home Page:
    http://rendramm2.wordpress.com
    :snobby: Ok ok ok ..... Thanks a lot ...


    i'm sure i need ur help again anytime ... :D
     
  17. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I am always here in the forum :D
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice