Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2007
    Location
    malaysia
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help, sending email from php script



    anyone know how to send email from php script without using Outlook? Before i've manage to do the email form but then outlook will pop up so i have to login outlook first. That is very unconvinient. Maybe someone can show me how to send email direct from php script or at least a reference?

    Thank you.

  • #2
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    PHP has a mail function
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #3
    Regular Coder
    Join Date
    Jun 2007
    Location
    N. Ireland
    Posts
    351
    Thanks
    16
    Thanked 4 Times in 4 Posts
    I would do the following:

    Code:
    <form method="post" action="/sendmail.php">
    <input type="submit" name="submit" value="Submit" />
    </form>
    and in sendmail.php:

    PHP Code:
    <?php
    if (isset($_POST['submit'])){
    $to 'admin_email';
    $subject 'email_subject';
    $message 'message to send';
    mail($to,$subject,$message);
    header('Location: /thankyou.php');
    exit;
    } else {
    header(Location: /back_to_form.php);
    exit;
    }
    ?>
    I would generally post the form to the same page that called it and inclde the above php code at the top of the page checking for posting and if not, display the form.

    Hope this helps.
    Daemonkin.
    If this was helpful, please add to my reputation
    Thousand Sons - Freelance Web Developer - ninetyonedegrees.com


  •  

    Posting Permissions

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