php mail problem

Discussion in 'PHP' started by OPETH, Jan 5, 2008.

  1. #1
    <?php 
    if (isset($_POST['email']))
    
    		$isim  = $_POST['isim'] ; 
    		$email = $_POST['email'] ;
    		$mesaj = $_POST['mesaj'] ; 
    		
    		
    		$baslik 		= "HTML Turkten Mesaj var.";
    		$kime 			= "info@htmlturk.com "; 
    		$mailbilgileri  	= "From:$email"; 
    		mail($kime, $baslik, $mesaj, $mailbilgileri);
    
    		
    		{
    		 
    		echo "Email formumuzu doldurduğunuz için teşekkürler."; 
    		}
    
    ?>
    Code (markup):
    I am trying to make a simple php mail script.it is working when put in another hosts. But
    it is not working in my host.
    Host firm recommend to use smtp.
    What I should about it?Please me!
     
    OPETH, Jan 5, 2008 IP
  2. Freewebspace

    Freewebspace Notable Member

    Messages:
    6,213
    Likes Received:
    370
    Best Answers:
    0
    Trophy Points:
    275
    #2
    If you are using a free host ,they do n't allow you send emails as users may abuse it
     
    Freewebspace, Jan 5, 2008 IP
  3. thapame

    thapame Well-Known Member

    Messages:
    739
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    180
    #3
    use this code


    
    <?php
    ini_set("SMTP","mail.yoursite.com"); //mail.yoursite.com should be your local smtp
    ini_set("smtp_port","25"); //25 should be your smtp port
    ini_set("sendmail_from","info@yoursite.com"); //info@yoursite.com should be your site email
    
    //all your php email code goes below
    ?>
    
    Code (markup):
     
    thapame, Jan 6, 2008 IP
  4. Javof

    Javof Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Steeply...
     
    Javof, Jan 6, 2008 IP
  5. OPETH

    OPETH Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Here is my codes:


    <html>
    <body>
    <head>
    <meta http-equiv="content-language" content="tr">
    <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>


    <?php
    if (isset($_POST['email']))
    {

    $isim = $_POST['isim'] ;
    $email = $_POST['email'] ;
    $mesaj = $_POST['mesaj'] ;


    $baslik = 'HTML Turkten Mesaj var.';
    $kime = 'info@htmlturk.com ';
    $mailbilgileri = 'From:$email';


    mail($kime, $baslik, $mesaj, $mailbilgileri);

    if(empty($isim) || empty($email) || empty($mesaj) )

    {
    echo "<h2>Lütfen boş bıraktığınız alanları doldurunuz.</h2><h2><a href='index.php?id=50'>Mail Sayfasına Geri Dön</a></h2>";
    }

    elseif (!eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$", $email))

    {
    echo "<h2>Geçersiz <b>E-Mail Adresi</b> yazdiniz!</h2><h2><a href='index.php?id=50'>Mail Sayfasına Geri Dön</a></h2>";
    }

    else

    {
    echo "Email formumuzu doldurduğunuz için teşekkürler.";
    }
    }
    ?>

    </body>
    </html>

    The in codes above, how can make smtp?
     
    OPETH, Jan 8, 2008 IP
  6. thapame

    thapame Well-Known Member

    Messages:
    739
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    180
    #6
    add these 3 line of code (make sure you edit mail.yoursite.com to your local smtp, 25 to your smtp port, to your email on your domain)

    ini_set("SMTP","mail.yoursite.com"); //mail.yoursite.com should be your local smtp
    ini_set("smtp_port","25"); //25 should be your smtp port
    ini_set("sendmail_from","info@yoursite.com"); //info@yoursite.com should be your site email

    above
    mail($kime, $baslik, $mesaj, $mailbilgileri);
     
    thapame, Jan 8, 2008 IP
  7. sunnyverma1984

    sunnyverma1984 Well-Known Member

    Messages:
    342
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    120
    #7
    does your host providing SMTP access? if no you should ask him to provide smtp
     
    sunnyverma1984, Jan 8, 2008 IP
  8. OPETH

    OPETH Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    <?php
    if (isset($_POST['email']))
    {
    ini_set("SMTP","mail.htmlturk.com");
    ini_set("smtp_port",25);
    ini_set("$email","info@htmlturk.com");



    $isim = $_POST['isim'] ;
    $email = $_POST['email'] ;
    $mesaj = $_POST['mesaj'] ;


    $baslik = 'HTML Turkten Mesaj var.';



    mail( $baslik, $mesaj,$isim, $mailbilgileri);

    if(empty($isim) || empty($email) || empty($mesaj) )

    {
    echo "<h2>Lütfen boş bıraktığınız alanları doldurunuz.</h2><h2><a href='index.php?id=50'>Mail Sayfasına Geri Dön</a></h2>";
    }

    elseif (!eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$", $email))

    {
    echo "<h2>Geçersiz <b>E-Mail Adresi</b> yazdiniz!</h2><h2><a href='index.php?id=50'>Mail Sayfasına Geri Dön</a></h2>";
    }

    else

    {
    echo "Email formumuzu doldurduğunuz için teşekkürler.";
    }
    }
    ?>

    These codes still arent working.
     
    OPETH, Jan 8, 2008 IP