9

How to send a large number of emails using the php and shell command

 3 years ago
source link: https://www.codesd.com/item/how-to-send-a-large-number-of-emails-using-the-php-and-shell-command.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

How to send a large number of emails using the php and shell command

advertisements

Here I am facing a problem when I am send email in loop. The Details is given below:

I have a csv file called email.csv. I am uploading this file and read the email from this csv file.I am using codeignitor framework. The code for reading the csv file and send the emails, the code is given as follows.

 $file = $_FILES['email_from_file'][tmp_name];
                        $handle = fopen($file,"r");

                        if (($handle = fopen($file,"r")) !== FALSE) {
                            while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                                $num = count($data);
                                for ($c=0; $c < $num; $c++) {
                                    $this->email->clear();
                                    $this->email->set_mailtype("html");
                                    $this->email->to(trim($data[$c]));
                                    $this->email->from('[email protected]');
                                    $this->email->subject($data['news_letter_info'][0]['subject']);
                                    $this->email->message($data['news_letter_info'][0]['template_body']);
                                    $this->email->send();
                                }
                            }
                            fclose($handle);
                        }

when I am sending the email its take too much time to execute and sending the email. And my browser also became hang. So is there have any possible way to send these emails using shell command which will execute the php script in the background.

Thank in advance.


Use this.

exec('php /<SERVER PATH>/send_bulkmail.php');

In your send_bulkmail.php use code to read file using fread() or file_get_content() and send mail in lood as you have done above.


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK