PHP mail problem

Discussion in 'PHP' started by aden, Mar 5, 2008.

  1. #1
    Hi there,

    I have an e-card system on my website, which was working fine until my host performed an upgrade from PHP4 to PHP5 a few days ago. Now the recepient does not receive the email telling him/her to view the e-card.The postcard system can be found on: www.tickity-boo.co.uk/site/postcard.php and the script is as follows:

    <?php
    require_once ("database.php");
    $page = $_SERVER['HTTP_REFERER'];
    $card = $_POST['postcard'];
    $stamp = $_POST['stamp'];
    $sname = $_POST['sname'];
    $semail = $_POST['semail'];
    $rname = $_POST['rname'];
    $remail = $_POST['remail'];
    $message = $_POST['message'];

    $database = new TB_Database;
    $dataLink = $database->DB_databaseConnect();
    $query = "INSERT INTO tbPost(post_card , post_stamp, post_sname, post_semail , post_rname, post_remail, post_message, post_date, post_active) VALUES ('$card', '$stamp', '$sname', '$semail', '$rname', '$remail', '$message', now(), '1')";
    mysql_query($query,$dataLink);
    $postid = mysql_query("SELECT MAX(post_id) FROM tbPost");
    $post = mysql_fetch_array($postid);

    if ($page=="http://www.tickity-boo.co.uk/site/postcard04.php")
    {
    $subject= $semail." has sent you an e-card";
    $header= "From: info@tickity-boo.co.uk\r\n";
    $header.= "Content-Type: text/html\r\n\r\n";
    $header.= "<html><p>Hi,</p>";
    $header.= "<p>You have been sent an e-card from ".$sname."</p>";
    $header.= "<p>It can be viewed at <a href=\"http://www.tickity-boo.co.uk/site/postview.php?post=".$post['MAX(post_id)']." \">www.tickity-boo.co.uk/site/postview.php?post=".$post['MAX(post_id)']."</p>";
    $header.= "</html>";

    mail($remail,$subject,"","MIME=Version:1.0\r\n$header");
    }
    mysql_close($dataLink);
    ?>


    Any help would be much appreciated.
    Many thanks,
    Aden
     
    aden, Mar 5, 2008 IP
  2. mab

    mab Active Member

    Messages:
    563
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    80
    #2
    i got the same problem :(
     
    mab, Mar 5, 2008 IP
  3. aden

    aden Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Any further to solving it? Also I keep being reffered to http://phpmailer.sourceforge.net/, but all I want is if possible to adapt/correct the existing script :(
     
    aden, Mar 5, 2008 IP
  4. andy@pmr

    andy@pmr Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hello,

    I have described the solution here:

    http://www.sitepoint.com/forums/showthread.php?t=535774
     
    andy@pmr, Mar 5, 2008 IP
  5. aden

    aden Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi,

    I replaced the code in the postsend.php file to:

    <?php

    require("class.phpmailer.php");

    require_once ("../classes/Database.php");
    $page = $_SERVER['HTTP_REFERER'];
    $card = $_POST['postcard'];
    $stamp = $_POST['stamp'];
    $sname = $_POST['sname'];
    $semail = $_POST['semail'];
    $rname = $_POST['rname'];
    $remail = $_POST['remail'];
    $message = $_POST['message'];

    $database = new TB_Database;
    $dataLink = $database->DB_databaseConnect();
    $query = "INSERT INTO tbPost(post_card , post_stamp, post_sname, post_semail , post_rname, post_remail, post_message, post_date, post_active) VALUES ('$card', '$stamp', '$sname', '$semail', '$rname', '$remail', '$message', now(), '1')";
    mysql_query($query,$dataLink);
    $postid = mysql_query("SELECT MAX(post_id) FROM tbPost");
    $post = mysql_fetch_array($postid);

    if ($page=="http://www.tickity-boo.co.uk/site/postcard04.php")
    {
    //$subject= $semail." has sent you an e-card";
    //$header= "From: info@tickity-boo.co.uk\r\n";
    //$header.= "Content-Type: text/html\r\n\r\n";
    //$header.= "<html><p>Hi,</p>";
    //$header.= "<p>You have been sent an e-card from ".$sname."</p>";
    //$header.= "<p>It can be viewed at <a href=\"http://www.tickity-boo.co.uk/site/postview.php?post=".$post['MAX(post_id)']." \">www.tickity-boo.co.uk/site/postview.php?post=".$post['MAX(post_id)']."</p>";
    //$header.= "</html>";
    //mail($remail,$subject,"","MIME=Version:1.0\r\n$header");

    $mail = new PHPMailer();
    $mail->IsSMTP(); // set mailer to use SMTP
    $mail->Host = "YOUR SMTP SERVER"; // specify main and backup server
    $mail->SMTPAuth = true; // turn on SMTP authentication
    $mail->Username = "YOUR SMTP USER NAME"; // SMTP username
    $mail->Password = "YOUR SMTP PASSWORD"; // SMTP password

    $mail->From = 'info@tickity-boo.co.uk';
    $mail->FromName = '';
    $mail->AddAddress($_POST['remail']);

    $mail->WordWrap = 50; // set word wrap to 50 characters
    $mail->IsHTML(true); // set email format to HTML

    $mail->Subject = $semail." has sent you an e-card";

    $mail->Body.= "<html><p>Hi,</p>";
    $mail->Body.= "<p>You have been sent an e-card from ".$sname."</p>";
    $mail->Body.="<p>It can be viewed at <a href=\"http://www.tickity-boo.co.uk/site/postview.php?post=".$post['MAX(post_id)']." \">www.tickity-boo.co.uk/site/postview.php?post=".$post['MAX(post_id)']."</p>";
    $mail->Body.= "</html>";

    $mail->AltBody = "Your mailer does not support HTML, sorry.";

    $mail->Send();
    }
    mysql_close($dataLink);
    ?>

    I also included the 3 files: class.phpmailer.php, class.smtp.php and phpmailer.lang-en.php in the same directory as as the postsend.php file
    , but now I get the error:

    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.
    Please contact the server administrator, webmaster@tickity-boo.co.uk and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.

    To check my mail I use webmail provided with the hosting company.

    Many thanks again
    Aden
     
    aden, Mar 6, 2008 IP