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 14 of 14
  1. #1
    ABA
    ABA is offline
    New Coder
    Join Date
    May 2009
    Posts
    27
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Need help with email ()

    Hey guys. Im pretty knew to php and I need some help with this please!

    I am trying to send out emails to customers based on a search and Im not sure how to do the email part of it. For example I would like to search for all my customers within a certain zip code and then be able to send an email to just those customers that came up in the search. I would like to somehow replace the "someone@example.com" for ALL my customers that came up in the search. Any suggestions?

    <?php

    $to = "someone@example.com";
    $subject = "Test mail";
    $message = "Hello! This is a simple email message.";
    $from = "someonelse@example.com";
    $headers = "From: $from";
    mail($to,$subject,$message,$headers);
    echo "Mail Sent.";

    ?>

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Do you need help with collecting all of the email addresses or help with formatting the mail() function with multiple email addresses?

  • #3
    ABA
    ABA is offline
    New Coder
    Join Date
    May 2009
    Posts
    27
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Hey thanks for the reply!!! I need help formatting it. I can exicute my email addresses on a page using the echo but I'm not sure how to send those same emails to the customers that show on my search page? That make since? Sorry I'm probably not explaining very good.

    When the result page comes up with that persons info and email I would like to somehow send an email to all those results.
    Last edited by ABA; 05-04-2009 at 10:45 PM.

  • #4
    ABA
    ABA is offline
    New Coder
    Join Date
    May 2009
    Posts
    27
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Any suggestions!!???? Anyone? Is it even possible to do what I'm trying to do??

  • #5
    Regular Coder
    Join Date
    Mar 2009
    Location
    United Kingdom
    Posts
    161
    Thanks
    6
    Thanked 28 Times in 28 Posts
    what is the source of these email address'? MYSQL im presuming?

  • #6
    ABA
    ABA is offline
    New Coder
    Join Date
    May 2009
    Posts
    27
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Yeah its MYSQL. Thats where there coming from.

  • #7
    Regular Coder
    Join Date
    Mar 2009
    Location
    United Kingdom
    Posts
    161
    Thanks
    6
    Thanked 28 Times in 28 Posts
    Well first you need the search script but it may look like some like this :

    PHP Code:
    <?

    $sql
    ="SELECT * FROM table_name"//Add criteria if you wish
    $result=mysql_query($sql);

    while(
    $rows=mysql_fetch_array($result)){
    $to $rows['email'];//change to email column in MYSQL database
    $subject "Test mail";
    $message "Hello! This is a simple email message.";
    $from "someonelse@example.com";
    $headers "From: $from";
    mail($to,$subject,$message,$headers);
    echo 
    "Mail Sent.";
    }
    ?>
    This will send an email to everyone in that mysql result.

  • #8
    ABA
    ABA is offline
    New Coder
    Join Date
    May 2009
    Posts
    27
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Oh ok I kind of think I see what your saying. So Can I tie that into my regular form or how do I tie this to my search page? I REALLY REALLY appreciate your help on this!!

  • #9
    Regular Coder
    Join Date
    Mar 2009
    Location
    United Kingdom
    Posts
    161
    Thanks
    6
    Thanked 28 Times in 28 Posts
    Yeah, whats your search script? could you post it please?

  • #10
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    I would recommend one email that you blind copy to all recipients.

  • #11
    ABA
    ABA is offline
    New Coder
    Join Date
    May 2009
    Posts
    27
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Ok Its a tone of code because I got everything else in there. Most of it you wont need. This isn't all of it but hopefully enough.
    Last edited by ABA; 05-05-2009 at 06:41 PM.

  • #12
    ABA
    ABA is offline
    New Coder
    Join Date
    May 2009
    Posts
    27
    Thanks
    10
    Thanked 0 Times in 0 Posts
    [
    <? /****************** START phpGoogleStoreLocator_result DIV *****************************/ ?>
    <div class='phpGoogleStoreLocator_result'>
    <?
    $counter++;
    $lat = $rows['lat'];
    $lon = $rows['lon'];
    $address = $rows['address'];
    $city = $rows['city'];
    $state = $rows['state'];
    $zip = $rows['zip'];
    $country = $rows['country'];
    $storename = $rows['storename'];
    $hours = $rows['hours'];
    $url = $rows['url'];
    if ($url == 'http://')
    {
    $url = '';
    }
    $image = $rows['image'];
    $notes = $rows['notes'];
    $phone = $rows['phone'];
    $email = $rows['email'];
    $id = $rows['id'];
    $image_url = $rows['image_url'];
    $distance = number_format($rows['distance'],2, '.', '');

    ?>

    <form method='post' action='mailform.php'>
    Email: <input name='email' type='text' /><br />
    Subject: <input name='subject' type='text' /><br />
    Message:<br />
    <textarea name='message' rows='15' cols='40'>
    </textarea><br />
    <input type='submit' />
    </form>";


    <? /************ START phpGoogleStoreLocator_result_location_anchor_number Div **************/ ?>
    <div class='phpGoogleStoreLocator_result_location_anchor_number'>
    <?echo "<a href=\"#\" onclick=\"show_marker(".$marker_id++.");\">$counter</a>";?>
    </div>
    <? /************ END phpGoogleStoreLocator_result_location_anchor_number Div **************/ ?>


    <? /************ START phpGoogleStoreLocator_result_location_distance Div **************/ ?>
    <div class=phpGoogleStoreLocator_result_location_distance>
    <? echo $distance; ?>
    </div>
    <? /************ END phpGoogleStoreLocator_result_location_distance Div **************/ ?>


    <? /************ START phpGoogleStoreLocator_result_location_image Div **************/ ?>
    <div class=phpGoogleStoreLocator_result_location_image>
    <?
    if ($image != '' && ($image_url != '' && $image_url != 'http://'))
    {
    echo "<a href=\"$image_url\"><img class='phpGoogleStoreLocator_result_location_image' src=\"$image\"></a>";
    }

    if ($image != '' && ($image_url == '' || $image_url == 'http://'))
    {
    echo "<img class='phpGoogleStoreLocator_result_location_image' src=\"$image\">";
    }
    ?>
    </div>
    <? /************ END phpGoogleStoreLocator_result_location_image Div **************/ ?>


    <? /************ START phpGoogleStoreLocator_result_location_data Div **************/ ?>
    <div class='phpGoogleStoreLocator_result_location_data'>

    <? /************ START phpGoogleStoreLocator_result_location_storename Div **************/ ?>
    <div class='phpGoogleStoreLocator_result_location_storename'>
    <?
    if ($url == '')
    {
    echo "$storename";
    }
    else
    {
    echo "<a href='$url'>$storename</a>";
    }
    ?>
    </div>
    <? /************ END phpGoogleStoreLocator_result_location_storename Div **************/ ?>

    <? /************ START phpGoogleStoreLocator_result_location_address Div **************/ ?>
    <div class='phpGoogleStoreLocator_result_location_address'>
    <? echo "$address"; ?>
    </div>
    <? /************ END phpGoogleStoreLocator_result_location_address Div **************/ ?>


    <? /************ START phpGoogleStoreLocator_result_location_city Div **************/ ?>
    <div class='phpGoogleStoreLocator_result_location_city'>
    <? echo "$city"; ?>
    </div>
    <? /************ END phpGoogleStoreLocator_result_location_city Div **************/ ?>

    <? /************ START phpGoogleStoreLocator_result_location_state Div **************/ ?>
    <div class='phpGoogleStoreLocator_result_location_state'>
    <? echo "$state"; ?>
    </div>
    <? /************ END phpGoogleStoreLocator_result_location_state Div **************/ ?>

    <? /************ START phpGoogleStoreLocator_result_location_zip Div **************/ ?>
    <div class='phpGoogleStoreLocator_result_location_zip'>
    <? echo "$zip"; ?>
    </div>
    <? /************ END phpGoogleStoreLocator_result_location_zip Div **************/ ?>

    <? /************ START phpGoogleStoreLocator_result_location_country Div **************/ ?>
    <div class='phpGoogleStoreLocator_result_location_country'>
    <? echo strtoupper("$country"); ?>
    </div>
    <? /************ END phpGoogleStoreLocator_result_location_country Div **************/ ?>





    <? /************ START phpGoogleStoreLocator_result_location_map_and_directions Div **************/ ?>
    <div class='phpGoogleStoreLocator_result_location_map_and_directions'>
    <a href="http://maps.google.com/maps?saddr=<? echo "$_POST[address] $_POST[city] $_POST[state] $_POST[zipcode] $_POST[country]"; ?>&daddr=<?
    if (use_coordinate($id, $db) == 'on')
    {
    echo "$lat,$lon($address, $city, $state, $zip, $country)";
    }
    else
    {
    echo "$address, $city, $state $zip $country";
    }
    ?>&hl=en">Get Directions</a>
    </div>
    <? /************ END phpGoogleStoreLocator_result_location_map_and_directions Div **************/ ?>


    </div>
    <? /************ END phpGoogleStoreLocator_result_location_data Div (Container for address stuff)**************/ ?>


    <div class="clearboth"></div>


    <? /************ START phpGoogleStoreLocator_result_location_phone Div **************/ ?>
    <div class='phpGoogleStoreLocator_result_location_phone'>
    <? echo "<b>$phone</b>"; ?>
    </div>
    <? /************ START phpGoogleStoreLocator_result_location_email Div **************/ ?>
    <div class='phpGoogleStoreLocator_result_location_email'>
    <? echo "<b>$email</b>"; ?>
    </div>
    <? /************ END phpGoogleStoreLocator_result_location_email Div **************/ ?>
    ]

  • #13
    ABA
    ABA is offline
    New Coder
    Join Date
    May 2009
    Posts
    27
    Thanks
    10
    Thanked 0 Times in 0 Posts
    I actually think I might of had it but it came up with an error because i think it needed a password to connect to my data base. Where in that code would I put a password to connect to my database? All my other stuff connects just fine. Once again Thanks again TONS for the help!

  • #14
    ABA
    ABA is offline
    New Coder
    Join Date
    May 2009
    Posts
    27
    Thanks
    10
    Thanked 0 Times in 0 Posts
    I got it now! Thanks


  •  

    Posting Permissions

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