email form - convert from PHP to SMTP

Discussion in 'PHP' started by kosaic, Mar 17, 2010.

  1. #1
    Morning,

    I have the following code on my site, when a user fills out a form, I post to a page with the following code. Pretty basic I know, however my host has disabled php mail on all it's servers for goodness knows how long.

    My question is, How do I re-jig this code to work with SMTP instead ? (sorry, not very handy with PHP myself)

    
    <?php
    
    $ip = $_POST['ip']; 
    $httpref = $_POST['httpref']; 
    $httpagent = $_POST['httpagent']; 
    $visitor = $_POST['visitor']; 
    $visitormail = $_POST['visitormail']; 
    $notes = $_POST['notes'];
    $attn = $_POST['attn'];
    
    
    if (eregi('http:', $notes)) {
    die ("Do NOT try that! ! ");
    }
    if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
    {
    echo "<h2>Please click 'BACK' and Enter a valid e-mail</h2>\n"; 
    $badinput = "<h2>Feedback was NOT submitted</h2>\n";
    echo $badinput;
    die ("Go back! ! ");
    }
    
    if(empty($visitor) || empty($visitormail) || empty($notes )) {
    echo "<h2>Please fill in all the required (<FONT COLOR='RED'>*</FONT>) fields</h2>\n";
    die ("Please click 'BACK' on your webbrowser and try again.<BR><CENTER><B>Your message has NOT been sent!</CENTER></B>"); 
    }
    
    $todayis = date("l, F j, Y, g:i a") ;
    
    $attn = $attn ; 
    $subject = $attn; 
    
    $notes = stripcslashes($notes); 
    
    $message = " $todayis [EST] \n
    Attention: $attn \n
    Message: $notes \n 
    From: $visitor ($visitormail)\n
    Additional Info : IP = $ip \n
    Browser Info: $httpagent \n
    Referral : $httpref \n
    ";
    
    $from = "From: $visitormail\r\n";
    
    
    mail("my_email@here.com", $subject, $message, $from);
    
    ?>
    
    Code (markup):
    Thanks for any and all help.

    Kosaic
     
    Last edited: Mar 17, 2010
    kosaic, Mar 17, 2010 IP
  2. Niku01

    Niku01 Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Search on phpclasses a smtp class .
     
    Niku01, Mar 17, 2010 IP
  3. guardian999

    guardian999 Well-Known Member

    Messages:
    376
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #3
    search phpmailer
    *remove underscore
     
    guardian999, Mar 18, 2010 IP