Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Using Cron Job To Send Out Email List

Featured Replies

 

 

I have a friend who sends out inservice information for about 50,000 teachers a couple times a week. I have set up a php page to check a database to find any unsent emails that he may has created and sends them to each of the teachers. He sends these out 2 to 3 times a week. I have been told that if you run this page from your computer, that emails are then marked as “spam” because of all of the emails being sent from that ip so I set up a Cron Job to run this page. Are there any problems with this? If so, what can I do about it?

 

 

  • Author

Here's what the code looks like after all of the variables have been stored:

 

$success = mail($to,$subject,$message,$headers);
if (!$success) {
echo "Mail failed .";
}else {
echo "Success " ;
}

Edited by gigman7

If you are not using a dedicated mail server it is likely that the server will baulk if you try to send more than 100 mails per hour. At least that is my experience with the majority of web hosts. Try using someone like Mailchimp. for this.

 

Also are you remembering to set the headers to Bcc the mails to each recipient? If not each of the 50,000 will receive a mail containing the email addresses of the other 49,999 recipients.

 

Here's a basic script I wrote for someone that reads the emails from a flat file, elist.txt. The script could be adapted to read from a database:

<?php
// read the list of emails from the file.
$email_list = file("elist.txt");

// count how many emails there are.
$total_emails = count($email_list);

// go through the list and trim off the newline character.
for ($counter=0; $counter<$total_emails; $counter++) {
   $email_list[$counter] = trim($email_list[$counter]);
   }

// implode the list into a single variable, put commas in, apply as $to value.
$to = 'you@example.com';
$bcc = implode(",",$email_list);

$subject = $_POST['subject'];
$message = $_POST['message'];

$headers = "From: you@example.com"."\r\n";
$headers .= "Bcc: $bcc"."\r\n";
$headers .= "Reply-To: someone@example.com"."\r\n";
$headers .= "X-Mailer: PHP v.". phpversion()."\r\n";
$headers .= "MIME-Version: 1.0"."\r\n";  
$headers .= "Content-Type: text/html; charset=iso-8859-1"."\r\n";

if ( mail($to,$subject,$message,$headers) ) {
   echo "The email has been sent!";
   } else {
   echo "The email has failed!";
   }
?>
 

However the flat file, the PHP script and the page with the form that set the subject and message need to be in a non-public area of the server or in a password protected folder. Leaving scripts like this lying around on your server where anyone can get their mitts on them is highly undesirable.

 

Hope I'm not teaching the world to spam here. :)

  • Author

If you are not using a dedicated mail server it is likely that the server will baulk if you try to send more than 100 mails per hour. At least that is my experience with the majority of web hosts. Try using someone like Mailchimp. for this.

 

Also are you remembering to set the headers to Bcc the mails to each recipient? If not each of the 50,000 will receive a mail containing the email addresses of the other 49,999 recipients.

 

Are you saying that if you use a similar code as what you have posted it would go out as "one" email?

 

I promise it is not spam.

 

Are you saying that if you use a similar code as what you have posted it would go out as "one" email?

 

I promise it is not spam.

 

 

It won't go out as one mail. It means that when it arrives in the recipients inbox they won't have the other 49,999 email addresses provided to them as each will receive it as a Bcc (Blind carbon copy). The only addresses should be that of the originator of the mail and the recipient.

 

I once received a newsletter mailing from an online magazine that came complete with over 6,000 addresses of other recipients. Now that is a spammers dream. :)

You run the risk of having your IP blacklisted. Sending out 50,000 emails a few times a week, without any sort of batch sending is just going to look like spam. That's why services like Sendgrid, Amazon SES and Mandrill exist in the first place, as well as the ability to handle high volumes of email.

Rallport also mentioned that you have no analytics to track bounce rates, open rates, clicks, and unsubscribes ect. Basically, all the stuff you need to know to manage email effectively, it's all guesswork otherwise.

 

Sending out 100,000 emails a month with Mandrill costs $17 and gives you the ability to create templates with full analytics. A third-party service looks like a logical choice to me.

Sending out that many emails using the mail() function. Really? Also, your script doesn't track messages that have failed to be delivered - something anyone would kinda need to know. E.g. send out 50,000 emails and 40,000 of them bounce, is something anyone would want to know due to the negative effect on ROI.

 

Your script is only suited to very low volume runs, certainly not the size the OP is talking about.

 

What parts of ...

 

 

If you are not using a dedicated mail server it is likely that the server will baulk if you try to send more than 100 mails per hour. At least that is my experience with the majority of web hosts. Try using someone like Mailchimp. for this

 

... and ....

 

 

Here's a basic script I wrote for someone

 

.. didn't you understand? :unsure:

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.