Results 1 to 11 of 11
  1. #1
    Join Date
    Jan 2005
    Posts
    7

    Unanswered: Need help sending html email

    hi everyone,
    i have a subscribe/unsubscribe form where people sign up to receive my newsletter. their email then goes into my database which i am using mysql. i found how to send regular text emails but i can't find any scripts how to send my newsletter to the list of subscribers in html format.

    Can someone please help me with a script that will send an html email to the list of people i have in my database? i don't want to have to send the email to each personal seperately and i don't want to use any mailing list software.

    thanks!
    kathy

  2. #2
    Join Date
    Jan 2005
    Posts
    10
    there are very much good newsletter script on www.hotscripts.com
    just check the programming language you use an seach the category newsletter mailing ....
    i bet u find something usefull and easy to install ;0)

  3. #3
    Join Date
    Jan 2005
    Posts
    7

    Still need help sending html email

    thanks for replying but i didn't want to use a mailing list script that's why i posted here for help. i already have a script in place to send the names to my database, now i just need a script that will allow me to send out an html email to my subscribers.

    kathy

  4. #4
    Join Date
    Jan 2005
    Posts
    10
    you dont have to use the full newsletter script u find on hotscripts
    just browse thru the code and search the snipets you need

    but here are some hints

    Code:
    // build a html file 
    // place {$name} where the name should be placed
    // {$text} where the text shoulb be
    
    // select you usernames and email adresses
    select name, email from db
    
    // read the html file into a string var
    $mailcode = fopen.....
    
    // to send html mail you have to add some mail header information
    // the rfc is a good place to look how a mail header should look like
    $header = "..from....reply to..... html.... charset ...date.." 
    
    
    while ( $row = mysql_fetch_array() ){
      $mailcode =  str_replace ( {$name}, $row[name], $mailcode );
      $mailcode =  str_replace ( {$text}, 'TEXT', $mailcode );
      if ( mail( $reciepient , $header ....) {
         echo "mail sent to $row[name] ";
      } 
    }
    this is just a hint this code wont work with copy and paste

  5. #5
    Join Date
    Jan 2005
    Posts
    7

    thanks for replying again

    i appreciate your hints and i understand that you want me to search for the coding, however, i have been searching for over a week now and since i'm new at this stuff it will be difficult for me to find what you are suggesting. so far i have only seen entire scripts for mailing lists and they are not what i want. i don't know how to take only what is needed for my task as you suggested. i'm really tired of searching and all i want is a code for sending html emails. now please don't think i'm lazy cause i found the code and even modified it for the first part of my task which was to set up the mailing list.

    and i even did more searching as you suggested but enough is enough for me.

    thanks again though for responding.
    kathy

  6. #6
    Join Date
    Jan 2005
    Posts
    10
    ok ok :0)

    i know its hard to browse thru code, especialy if you are new in this stuff.

    ok, if you use php and mysql i can help you.
    i can modify one of my scripts and post a download link here

    i try to do enough comentary so you can easily find and understand the codeparts you have to change

    /*---- EDIT ---- */

    i added a "zip-file" including 2 files
    the html template and
    the php file to send the email

    /*---- EDIT ---- */

    the_spas
    Attached Files Attached Files
    Last edited by the_spas; 01-18-05 at 06:42.

  7. #7
    Join Date
    Jan 2005
    Posts
    7

    Thumbs up thanks for the help!!!

    i really appreciate you helping me out spas, and i will try out the code and let you know if i have succeeded. lol. i'm just learning about php and mysql and it's very exciting but i'm a neebie trying to get her feet wet. lol.

    but i also understand that we must try ourselves to get the answers instead of turning to forums for the answers. i got stuck and that's why i posted here cause let me tell you i will try my best to get my answers without asking for help. lol. got that from going to school and you remind me of one of my teachers. lol.

    you must be a teacher or a php/mysql Master? lol.
    thanks again,
    kathy

  8. #8
    Join Date
    Jan 2005
    Posts
    7

    It works but....

    hi spas, okay i got it to work (sent myself a test email) but i don't see where i can send the mail to more than one person by having the emails come from mysql database. did i miss something?

    please help some more?

    thanks
    kathy

  9. #9
    Join Date
    Jan 2005
    Posts
    10
    :0) *BIGGRIN*
    no im not a teacher at all

    and im very happy if im stuck and somebody helps me out, so never mind

    ok lets see:
    the script is sending just one mail this is correct

    ok you want to send the mail to some users from a mysql database
    if you inserted the users somehow into the table i asume you can connect to the database and know how to query it.

    so here is some more code that could help you on your quest
    PHP Code:
    // debug param first :0)
    define('DEBUG'true);

    // then make the db connect 

    // write the query thats selects the users you want to send the email
    // you should query the fields explicit not by * if you dont need all of them
    // if there is no condition like (active = 1)
    // and you want them all to recieve the mail
    // just delete the 'WHERE my condition' part
    $query "SELECT * FROM recipient_table WHERE my condition";
    // perform the query and get the mysqlresult
    $result mysql_query($query);

    // while the result list is not at its end
    while ( $row mysql_fetch_array($resultMYSQL_ASSOC) ) {
         
    // everything inside the while loop is done for every user in the list
         // to see what happens just try this in DEBUG mode
         
    id DEBUG ) {
              
    // $row is now a array that holds one row of the mysql result
              // you can access the data by $row[mysql_tabel_column_name]
              
    echo 'The Name: ' $row[table_column_name] . ' <br />';
              echo 
    'The Email: ' $row[table_column_email] . ' <br />';
         } else {     
              
    // if you have understand how this works
              // you can change DEBUG to false
              // to send the mail do something like this
              
    $recipient_mail $row[table_column_email];
              
    $recipient_name $row[table_column_name];
              
              
    // the template stuff for ever user should be made here
              // i leave this commented
              // this is similar to the code you allready have the only difference is
              // that the name should be changed and the result of this operation 
              // is stored in another variable so the original $mail_text
              // is not overwriten so you can still use it inside this loop
              // without reading the tamplates again and again
              
              // $user_mail = str_replce('{$name}', $recipient_name, $mail_text);
              // $mail_sent = mail($recipient_mail, $subject, $user_text, $header);
              
    if ( $mail_sent ) {
                   echo 
    'Mail sent to: ' $recipeint_name ' &lt;' $recipient_mail '$gt;<br />';
              } else {
                   echo 
    ' Error! :0) ';
              }
         }

    i have written this without testing, you should just play around a bit with seme mysql selects and some while loops to get familiar with this
    try some test loops that return somthing like this

    HTML Code:
    From Database:
    Name: John Doe, Email john@doe.com
    Name: Jane Doe, Email jane@doe.com
    Name: the spas, Email the_spas@has_no_mail.com
    ....
    thats it :0)

    gl hf

    ahhhh and by the way dont send mails to a big amount of recipients
    you will kill the mailserver :0)
    therefor use the mail header bcc: option or do the sendings in bundles
    so you send 20 mails wait 10 seconds send 20 mails wait 10 sec.......
    Last edited by the_spas; 01-19-05 at 08:59.

  10. #10
    Join Date
    Jan 2005
    Posts
    7

    oh gosh, lol.

    hi spas,
    ummm yes i got the names into the table but i don't know how to do a query with mysql. know how to do it with access but not mysql. gosh maybe i should using access or a text file to make life simplier? lol.

    okay, i'll see if i can figure that part out today.

    thanks,
    kathy

  11. #11
    Join Date
    Jan 2005
    Posts
    7

    i give up. lol.

    hi spas,
    i don't know what i'm doing and i feel like i'm wasting time trying to figure this stuff up. thanks for the help but i can't figure this stuff out. i know it's simple but i can't grasp what you want me to do. i don't know where i'm suppose to put all of this coding you sent me. i was able to run a query in mysql but that's it.

    sorry

    kathy

Posting Permissions

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