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 11 of 11
  1. #1
    Regular Coder
    Join Date
    Jul 2003
    Location
    Ontario, Canada
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating a mailing list with PHP

    Alright, here's what I want to do.

    1. User signs up to receive emails from my website (let's assume I'll get a tonne of users).
    2. User gets added to a database of users.
    3. There is a table in the database containing many different emails. (There are approximately 40 different emails).
    4. Based on the users DOB, they will receive a certain email (hense the reason for the different emails in another table).
    5. Once a week, the site admin will click on a send email button that will automatically send the email to these users.

    I've tried using PHP's mail function, but it doesn't realyl like me doing that

    Please, anyone who has experience doing this, I need your help!

    Thanks

    IC

  • #2
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    I have a mailing list set up and it works fine with the mail function.

    What was your problem?

  • #3
    Regular Coder
    Join Date
    Jul 2003
    Location
    Ontario, Canada
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts
    how many users are subscribed?

  • #4
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    couple hundred, y?

  • #5
    Regular Coder
    Join Date
    Jul 2003
    Location
    Ontario, Canada
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oh, just wanted to know if it was a volume issue

    currently my list is only up to 70 or so.

    The problem I'm having is that some addresses are not having the email delivered to them. I'm doing more research, but I'm currently in the midst of re-writing the script to use BCC instead of sending one email per person.

    Thanks for your help, any more tips/hints would be much appreciated!

    IC

  • #6
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    I used to use it in Bcc, but decided to change it to a loop using many mail functions, it may take more time etc, but only admins have to use it so they know it is slower than it could be.

    Are you sure all the email addresses are correct?

  • #7
    Regular Coder
    Join Date
    Jul 2003
    Location
    Ontario, Canada
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah, I'm sure the emails are correct. That's why it's not making any sense!

    Anyways, I'm currently doing it in a loop with mail mail function calls, but I've been advised against that several times.

    Can you post a code snippet for me to see how you're doing it?

    Thanks

    IC

  • #8
    Senior Coder
    Join Date
    Apr 2005
    Location
    Colorado, United States
    Posts
    1,208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    For a service I am currently coding (I don't have the code with me unfortunately) I am sending alerts when a certain service is updated, and I use BCC for similar emails (of the same service), and mail loops for multiple BCC emails of different services.

    Is sendmail configured on your server? You may need to edit php.ini to have your sendmail directory, or you might want to use a SMTP server instead.
    "$question = ( to() ) ? be() : ~be();"

  • #9
    Regular Coder
    Join Date
    Jul 2003
    Location
    Ontario, Canada
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, I'm using a third party host, so I don't have the ability to configure their server. Senmail is configured, but I think the problem I'm having is due to specific limitations set on the sendmail (I think there's only a cetain number of emails allowed per minute or somthing strange like that.

    How would I use another SMTP server?

    Can I do that directly from PHP?

    Thanks

    IC

  • #10
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Youc could do that with fsockopen sending the right headers... but I would need to look things up in a a few places to get you the anwser...
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #11
    Senior Coder
    Join Date
    Apr 2005
    Location
    Colorado, United States
    Posts
    1,208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code by Terminal, user contributed notes: fsockopen()

    PHP Code:
    <?php

       $handle 
    smtp_connect($smtp_server2530111);
       echo 
    smtp_command($handle"EHLO $domain\r\n"11);
       echo 
    smtp_command($handle"MAIL FROM:<$from_mail>\r\n"11);
       echo 
    smtp_command($handle"RCPT TO:<$to_mail>\r\n"11);
       echo 
    smtp_command($handle"DATA\r\n"11);
       echo 
    smtp_command($handle"$message\r\n.\r\n"11);
       
    // don't do it like this - it will hang up
       // echo smtp_command($handle, "$message", 1, 1);
       // echo smtp_command($handle, "\r\n.\r\n", 1, 1);
       
    echo smtp_command($handle"QUIT\r\n"11);
       
    smtp_close($handle); 
       
       
       function 
    smtp_connect($host$port$timeout=30$echo_command=False$echo_response=False$nl2br=False)
       {
           
    $errno 0;
           
    $errstr 0;
           if(
    $echo_command)
           {
               if(
    $nl2br) { echo nl2br("CONNECTING TO $host\r\n"); }
               else { echo 
    "CONNECTING TO $host\r\n"; }
           }
           
    $handle fsockopen($host$port$errno$errstr$timeout);
           if(!
    $handle)
           {
               if(
    $echo_command)
               {
                   if(
    $nl2br) { echo nl2br("CONNECTION FAILED\r\n"); }
                   else { echo 
    "CONNECTION FAILED\r\n"; }
               }
               return 
    False;
           }
           if(
    $echo_command)
           {
               if(
    $nl2br) { echo nl2br("SUCCESS\r\n"); }
               else { echo 
    "SUCCESS\r\n"; }
           }
           
    $response fgets($handle,1);
           
    $bytes_left socket_get_status($handle);
           if (
    $bytes_left 0) { $response .= fread($handle$bytes_left["unread_bytes"]); }
           if(
    $echo_response)
           {
               if(
    $nl2br) { echo nl2br($response); }
               else { echo 
    $response; }
           }
           return 
    $handle;
       }

       function 
    smtp_command($handle$command$echo_command=False$nl2br=False)
       {
           if(
    $echo_command)
           {
               if(
    $nl2br) { echo nl2br($command); }
               else { echo 
    $command; }
           }
           
    fputs($handle$command);
           
    $response fgets($handle,1);
           
    $bytes_left socket_get_status($handle);
           if (
    $bytes_left 0) { $response .= fread($handle$bytes_left["unread_bytes"]); }
           if(
    $nl2br) { return nl2br($response); }
           else { return 
    $response; }
       }
       
       function 
    smtp_close($handle)
       {
           
    fclose($handle);
       }
    ?>
    "$question = ( to() ) ? be() : ~be();"


  •  

    Posting Permissions

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