Link to home
Start Free TrialLog in
Avatar of umaxim
umaximFlag for United States of America

asked on

Email form

Hi I want to create system to send email. I know if i run script and php file have ignore_user_abort() function it will work even user close window. It is ok. But i want to create additional function to show up how many % it have done. I decide to use ajax and update it every 5 seconds. But problem i did not know how i can get result from file. I think to create txt file and every 10 second write result there but i think it will use a lot of memory of server. What you can recommend me?
Avatar of ramelong
ramelong
Flag of Argentina image

I suggest you to use a MySQL table which could register the status of every email as well as their errors... For a % you just use two COUNT(*) in order to catch the amount of records pf this process and the amount of records processed (% is the ratio between both).
Avatar of umaxim

ASKER

So i make db with email and every time when i send email it put like 1 in send row. So i count how many rows with send =0 and check it.
It is a possibility.
If you send batches of mails, I should add a field with the ID of this batch. Furthermore you can use other field to register errors of the sent (for future features).
For instance, this should be a table slice:
···-+--------+------------------------------+------+-------+-···
··· | batch  | email                        | sent | error | ···
···-+--------+------------------------------+------+-------+-···
··· ·        ·                              ·      ·       · ···
··· | 15     | user1@domain1.com            | 1    | 0     | ···
··· | 15     | user2@domain2.com            | 1    | 0     | ···
··· ·        ·                              ·      ·       · ···
··· | 16     | user3@domain3.com            | 0    | 0     | ···
··· | 16     | user4@domain4.com            | 0    | 0     | ···
··· | 16     | user5@domain5.com            | 0    | 0     | ···
··· ·        ·                              ·      ·       · ···
···-+--------+------------------------------+------+-------+-···

Open in new window

Avatar of umaxim

ASKER

Eap this is a good idea i think i will use it. Thank you. But how make script to make less usage of mysql. Becouse if i will have 100 000 email and every time when i send email i will update mysql it will just kill my server. How you think if it possible to compite few of emails like update mysql every 10 emails.
Well, let me think and I answer you early in  the mornirg... I'm going to sleep right now ;)...

But I let you a question: Do you think execute this operation either by a browser or as an executable in background?
You can dose your server effort by executing a sleep(1) between, for instance, 20 emails sent... But the heaviest duty is for the SMPT and not for MySQL...
Avatar of umaxim

ASKER

No my client want execute by browser. This why i use ajax and progressbar.
ASKER CERTIFIED SOLUTION
Avatar of ramelong
ramelong
Flag of Argentina image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of umaxim

ASKER

Maybe i think i will make 2 table one is emails another is flag like send or not send. So i will use regular count of mysql rows and than take them by  50 of them and every 50 i will update mysql.  It will take away many mysql query.

And i was think about different type of counting of how many is done. I was think to create a file like txt and save there result of the script every 10-15 emails sended. But I do not know if it will take a lot of time to rewrite txt file by php.
Create a txt always needs more processing resources from your server than using MySQL (since you are using the hard disks and MySQL use a cache designed to perform this kind of tasks).

Even more, when a file increase its size, the PHP file system have performance issues to handle it.
The use of txt is for small amount of data (like passwords or preferences) or to create log files that somebody will read someday (when a problem occurs)...

Anyway, it's your call ;)
Avatar of umaxim

ASKER

No i will use mysql for emails i just want to save result like in txt file it will be number of procents done and how many email get error. Nothing else.
Ah Ok.
Well, seems like you are ready to create your oun mailing system :)

Have you any other question about this? In other case, I hope you have success on your task!
Avatar of umaxim

ASKER

Thank you for help