0

I have two servers,ServerA & ServerB.ServerA do not support mass mailing while ServerB do support(I have more than 4000 email addresses in MySQL table).

On ServerA I am creating HTML for emails and On ServerB I put script to send emails.I run this code on ServerA

ob_end_clean();
header("Connection: close");
ignore_user_abort(); // optional
ob_start();
echo ('Sending email...');
$size = ob_get_length();
header("Content-Length: $size");
ob_end_flush();     // Will not work
flush();            // Unless both are called !
$postdata = http_build_query(
array(
    'subject'=>'Latest Rentals Properties',
    'message' => $message   //email body html
     )
);
$opts = array('http' =>
array(
    'method'  => 'POST',
    'header'  => 'Content-type: application/x-www-form-urlencoded',
    'content' => $postdata
     )
  );
$context  = stream_context_create($opts);
$result = @file_get_contents('http://ServerB.com/send_email.php', false, $context);
if($http_response_header[0]=="HTTP/1.1 404 Not Found"):echo "404";
elseif($http_response_header[0]=="HTTP/1.1 200 OK"):echo "OK";
else "ERROR";

On ServerB.com,send_email.php has this code to send email(I am using class.phpmailer.php)

$subject = $_REQUEST['subject'];
$message1 = $_REQUEST['message'];
$mail->SetFrom("from@ServerB.com", '');
$rs = $oBj->query("SELECT email FROM `crm_test_emails` where is_active = 1 ");
while ( $rw = $oBj->row($rs) ){
$email= $rw['email'];
$message1         = str_replace("########",$email,$message1);
$mail->AddAddress($email, "");
$mail->Subject    = $subject;
$mail->MsgHTML($message1);
$mail->Send();
}

My questions are

  1. One email address getting more than 500 same emails(sending duplicates).
  2. Email goes directly to spam.
  3. I do not want any one to see others emails.Right now one email id can see all others to whom i sent email.

I asked questions on priority,first one is more important and so on.. Please guide me where i have issue in code logic.

Prix
  • 19,417
  • 15
  • 73
  • 132
user3244721
  • 714
  • 2
  • 11
  • 29

3 Answers3

0

May I suggest using a service such as http://www.mailgun.com/. Mass email sending requires a huge amount of effort to get it right (see How to send 100,000 emails weekly?).

Mailgun gives the first 10,000 emails free every month so this service would be free if you were sending these emails once or twice a month. If you do send them weekly, their prices are really cheap anyway.

Community
  • 1
  • 1
James T
  • 499
  • 2
  • 5
  • Whats wrong with my code?I tried few services but there were alot of issues,they asked about the source of emails etc etc – user3244721 Mar 23 '14 at 10:29
  • 1
    If you can't reply about source of your addresses than you're asking for troubles. Read the links above (especially the 100K emails weekly) and think for a while where are you now and where you want to go. – pawel7318 Mar 23 '14 at 11:47
0

Check Subscribe - Open-source project - a service which helps you in setting up Mail Sender application using GAE.

Its easy to install.

Why Subscribe?

  • Handles multiple applications. Just add your application's specific private key. It will handle all your unsubscriptions application wise.
  • Handles multiple sender depending on your type of mails. Add all sender's email address in your appengine application.
  • No need to handle your unsubscriptions while sending emails to your customers / users. Service already taking care of it. Append's unsubscribe link along with given body.
Love Sharma
  • 1,981
  • 1
  • 18
  • 37
-1

for question one i m checking your code

for question 2 You need to make sure your email signing server is has same domain name as you sending email address any ways this is a long topic some details are here

http://sendgrid.com/blog/10-tips-to-keep-email-out-of-the-spam-folder/

for question 3

please add all address to BCC Addressees not main address send email as Blind copy

m-farhan
  • 1,436
  • 13
  • 14
  • `BCC` can still be read so you will pretty much give out your list of emails which is not good. – Prix Mar 23 '14 at 10:05
  • @Prix please increase you knowledge read this : http://en.wikipedia.org/wiki/Blind_carbon_copy – m-farhan Mar 23 '14 at 10:11
  • 1
    Looks like reading is not your strong point, from your own link, **attention to the latter part after the last comma:** `Depending on email software, the tertiary recipients may only see their own email address in Bcc, or they may see the email addresses of all recipients.` – Prix Mar 23 '14 at 10:15
  • To and cc, yes. But not bcc though. – corn on the cob Sep 29 '20 at 14:29