Results 1 to 10 of 20

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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.

  2. #2
    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>  
    ';}

  3. #3
    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.

  4. #4
    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;

  5. #5
    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>

  6. #6
    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 ?');
    }

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
  •