Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

php EMAIL error

  • 22-05-2009 01:06PM
    #1
    Registered Users, Registered Users 2 Posts: 8,070 ✭✭✭


    [PHP]
    $fromx = $_GET["EMAIL"];


    if($fromx == null)
    {
    $xx = "noreply@company.ie";;
    }
    else
    {
    $xx = $_GET["EMAIL"];
    }

    $from = $xx;
    $to = "recipient@mail.com";
    $subject = "SALE now on !";

    sendHTMLemail($HTML,$from,$to,$subject);
    }


    function sendHTMLemail($HTML,$from,$to,$subject)
    {
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

    $headers .= "From: $from\r\n";

    if (mail($to,$subject,$HTML,$headers))
    {
    echo("Thank You");
    echo $from;
    echo "<br>";
    }
    else{echo("error");}
    }

    [/PHP]

    Keep getting error, unless i explicitly set $from to a string like "example@ss.com";


Comments

  • Registered Users, Registered Users 2 Posts: 6,680 ✭✭✭daymobrew


    What error are you getting?
    Are you sure that 'EMAIL' is being received by the form.


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    you could verify if you are getting an email in the QS
    [php]
    $fromx = isset($_GET["EMAIL"]) ? trim($_GET["EMAIL"]) : "";
    if($fromx == "") die("No email available");
    [/php]


  • Registered Users, Registered Users 2 Posts: 8,070 ✭✭✭Placebo


    i printed it out, just made the code simpler there.
    And it prints either.

    Is there anyway i can identify what exactly the error is [printing the specific error] ?

    thanks


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    fis this php error first and see
    [php]
    $xx = "noreply@company.ie";; // double ;; should be single ;
    [/php]


  • Registered Users, Registered Users 2 Posts: 8,070 ✭✭✭Placebo


    Sorry i just made a typo since i was clearing up the code to post it up here.
    So ;; are not in my code.


  • Advertisement
  • Closed Accounts Posts: 1,200 ✭✭✭louie


    try this
    [php]
    $fromx = isset($_GET["EMAIL"]) && $_GET["EMAIL"] != "" ? $_GET["EMAIL"] : "noreply@company.ie";

    $from = $xx; //what's this supposed to be?
    $to = "recipient@mail.com";
    $subject = "SALE now on !";

    sendHTMLemail($HTML,$from,$to,$subject);


    function sendHTMLemail($HTML,$from,$to,$subject){
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= "From: $from\r\n";

    if (mail($to,$subject,$HTML,$headers)){
    echo "Thank You" . $from . "<br />";
    }else{
    echo "error sending email";
    }
    }
    [/php]


  • Registered Users, Registered Users 2 Posts: 8,070 ✭✭✭Placebo


    Thanks louie, basically cause the we use phplist to send newsletters from the explicitly define email, it was blacklisted buy our hoster, thus all the trouble ! :mad:

    when checking to see if variable is empty, will the following suffice ?


    [PHP]
    if (!isset($fromx) || ($fromx==null) || ($fromx==""))
    {
    $from = trim("explicitlyDefined@mail.com");

    }
    else
    {
    $from = trim($_GET["EMAIL"]);
    }[/PHP]


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    there is a simpler way
    [php]
    if (empty($fromx)){
    $from = trim("explicitlyDefined@mail.com");
    }else{
    $from = trim($_GET["EMAIL"]);
    }

    // or a quicker way
    $from = empty($fromx) ? "youremail@mail.ie" : trim($_GET["EMAIL"]);
    [/php]


  • Registered Users, Registered Users 2 Posts: 8,070 ✭✭✭Placebo


    actually, only after realising, the problem was that onSUBMIT, the get value dissappeared. Im assuming its cause the forum is post?

    so i passed it in as a hidden input field and then also good practice would be to have the forum action as <?php echo 'name.php?EMAIL='.$Getvar; ?>

    so the parameter stays after submission.


Advertisement