Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: Day 12 - Sending Mail From PHP - Become PHP Expert in 30 days

  1. #11
    Join Date
    Nov 2004
    Location
    India
    Posts
    65

    Default

    http://php.flashwebhost.com/stefin/contact.php

    Code:
    <?php
    
    
    if (isset($_POST['submit'])) {
       $fromEmail = $_POST['fromEmail'];
        $body = $_POST['body'];
        mail('[email protected]','Message from web site', $body,
    'From: ' . $fromEmail . "\n\r");
        echo 'Thank you for contacting us.';
    } else {
    
    
    echo
     
    '<!doctype html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">  
    <title>Contact Us</title>
    </head>
    <body>
    <form action="contact.php" method="POST">  
    Email<br>    <input type="text" name="fromEmail"><br>   
    Message<br>  <textarea name="body" cols="30" rows="10"></textarea>  
    <br>    <button type="submit" name="submit" value="submit">Send Mail</button></form>
    </body></html>  
    ';}

  2. #12
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    Quote Originally Posted by stefin View Post
    http://php.flashwebhost.com/stefin/contact.php

    Code:
    <?php
    
    
    if (isset($_POST['submit'])) {
       $fromEmail = $_POST['fromEmail'];
        $body = $_POST['body'];
        mail('[email protected]','Message from web site', $body,
    'From: ' . $fromEmail . "\n\r");
        echo 'Thank you for contacting us.';
    } else {
    
    
    echo
     
    '<!doctype html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">  
    <title>Contact Us</title>
    </head>
    <body>
    <form action="contact.php" method="POST">  
    Email<br>    <input type="text" name="fromEmail"><br>   
    Message<br>  <textarea name="body" cols="30" rows="10"></textarea>  
    <br>    <button type="submit" name="submit" value="submit">Send Mail</button></form>
    </body></html>  
    ';}
    Very nice script :)

    If [email protected] is not your email address, it is better change it. If not if some one submit that form, we will mail the content to [email protected], that will be like sending spam.. as he don't want us to send him such mails.
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  3. #13
    Join Date
    Sep 2003
    Location
    india
    Posts
    11,527

    Default

    Code:
    <?php
    if (isset($_POST['submit'])) {
         $formEmail = $_POST['formEmail'];
        $body = $_POST['body'];
        mail('[email protected]', 'Message from Skype', $body , 'From: ' . $fromEmail . "\n\r");  
         echo 'Thanks for Contacting us';
        } else {
        echo
    
    
    
    
    '<!doctype html>
    <html lang="en">
    <head>
     <meta charset = "UTF-8">
    <title> Contact Us </title>
    </head>
    
    
    <body>
    <form action= "form.php" method="POST">
     	Email <br>
    	<input type="text" name="fromEmail"> <br>
    	Message <br>
     	<textarea name="body" cols="30" rows="10"></textarea>
            <br>
            <button type="submit" name="submit" value="submit"> Send Mail </button>
     </form>
    </body>
    </html>';}
    http://php.flashwebhost.com/annie/form.php

  4. #14
    Join Date
    Nov 2009
    Posts
    76,596

    Default

    http://php.flashwebhost.com/sherly/mailform.php

    Code:
    <?php
    if (isset($_POST['submit'])) {
         $formEmail = $_POST['formEmail'];
        $body = $_POST['body'];
        mail('[email protected]', 'Message from Web Site', $body , 'From: ' . $fromEmail . "\n\r");  
         echo 'Thanks for Contacting us';
        } else {
    
    echo
    
    
    '<!doctype html>
    <html lang="en">
    <head>
     <meta charset = "UTF-8">
    <title> Contact Us </title>
    </head>
    
    
    <body>
    <form action= "mailform.php" method="POST">
         Email <br>
        <input type="text" name="fromEmail"> <br>
        Message <br>
         <textarea name="body" cols="30" rows="10"></textarea>
            <br>
            <button type="submit" name="submit" value="submit"> Send Mail </button>
     </form>
    </body>
    </html>';}
    Last edited by sherlyk; 06-04-2014 at 05:47 AM.

  5. #15
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    Quote Originally Posted by annie View Post
    Code:
    <?php
    if (isset($_POST['submit'])) {
         $formEmail = $_POST['formEmail'];
        $body = $_POST['body'];
        mail('[email protected]', 'Message from Skype', $body , 'From: ' . $fromEmail . "\n\r");  
         echo 'Thanks for Contacting us';
        } else {
        echo
    
    
    
    
    '<!doctype html>
    <html lang="en">
    <head>
     <meta charset = "UTF-8">
    <title> Contact Us </title>
    </head>
    
    
    <body>
    <form action= "form.php" method="POST">
     	Email <br>
    	<input type="text" name="fromEmail"> <br>
    	Message <br>
     	<textarea name="body" cols="30" rows="10"></textarea>
            <br>
            <button type="submit" name="submit" value="submit"> Send Mail </button>
     </form>
    </body>
    </html>';}
    http://php.flashwebhost.com/annie/form.php

    When mail is submitted, it will be sent to [email protected]

    PHP Code:
    mail('[email protected]''Message from Skype'$body 'From: ' $fromEmail "\n\r"); 
    That can result in spam complaint as you don't own that email address. So make sure you set it to your email address, so only you get the email.

    You can delete the script later, if not spam bots will find it and sent spam message using the contact us form, this is why many sites use Captcha on contact forms.
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  6. #16
    Join Date
    Apr 2005
    Posts
    46,704

    Default

    http://php.flashwebhost.com/mini/email.php

    Code:
    <?php
    
    if (isset($_POST['submit'])) {
        $fromEmail = $POST['fromEmail'];
        $body = $_POST['body'];
        mail('[email protected]','Message from web site', $body, 'From: ' . $fromEmail . "\n\r");
        echo 'Thank you for contacting us.';
    } 
    
    else {  echo
    
        '<!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Contact Us</title>
    
    http://php.flashwebhost.com/mini/email.php
    
    <form action="email.php" method="POST">
        Email<br>
        <input type="text" name="fromEmail"><br>
        Message<br>
        <textarea name="body" cols="40" rows="10"></textarea>
        <br>
        <button type="submit" name="submit" value="submit">Send Mail</button></form>
    
    </body>
    </html>  
    ';}

  7. #17
    Join Date
    Jan 2008
    Location
    india,kerala-god's own country
    Posts
    14,007

    Default

    http://php.flashwebhost.com/ramesh/day-12/contact1.php

    PHP Code:
    <?php
    if (isset($_POST['submit'])) {  

      
    $fromEmail $_POST['Email'];   

     
    $body $_POST['body'];  

     
    mail('[email protected]','Message from web site'$body'From: ' $Email);  

      echo 
    'Thank you for contacting us.';} 

    else {   

    echo 

    '<!doctype html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">  
    <title>Contact Us</title>
    </head>
    <body>
    <form action="contact1.php" method="POST">  
      Email<br>    <input type="text" name="Email"><br>   
     Message<br>  <textarea name="body" cols="30" rows="10"></textarea>  
      <br>    <button type="submit" name="submit" value="submit">Send Mail</button></form>
    </body></html>  
    '
    ;}
    Last edited by rameshxavier; 06-18-2014 at 11:44 AM.

  8. #18
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    DAY 12 PHP PROGRAMMING

    http://php.flashwebhost.com/tom/day_12_ex_1.php

    PHP Code:

    <?php
    $toEmail 
    'php.flashwebhost.com';$subject 'Email Notification';$body 'Welcome to our Email Service';
    mail($toEmail$subject$body);
    echo 
    'Mail sent to ' $toEmail;

  9. #19
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    DAY 12 PHP PROGRAMMING

    http://php.flashwebhost.com/tom/day_12_ex_3.html

    Code:
    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Contact Us</title>
    </head>
    <body>
    
    
    <form action="day_12_ex_3.php" method="POST">
        Email<br>
        <input type="text" name="fromEmail"><br>
        Message<br>
        <textarea name="body" cols="30" rows="10"></textarea>
        <br>
        <button type="submit" name="submit" value="submit">Send Mail</button>
    </form>
    
    
    </body>
    </html>

  10. #20
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    Code:
    <?php
    
    
    if (isset($_POST['submit'])) {
        $fromEmail = $POST['fromEmail'];
        $body = $_POST['body'];
        mail('[email protected]','Message from web site', $body, 'From: ' . $fromEmail . "\n\r");
        echo 'Thank you for contacting us.';
    } else {
        die('Why are you here ? Want to hack my Script ?');
    }

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •