clintxp Posted March 8, 2007 Share Posted March 8, 2007 I am trying to mass mail an email. The emails are sent successfully (no errors) but sometimes the email arrives and sometimes never arrives my code is attached. I don't think there's something wrong with the code because sometimes it arrives. thanks for reading [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
vbnullchar Posted March 8, 2007 Share Posted March 8, 2007 Each line should be separated with a LF (\n). Lines should not be larger than 70 characters $message = " <html> </body> <span class=fs13>Dear $name<br><br> <img src=http://www.bitsandbytesmalta.com/mailinglist/picture.jpg border=0><br><br><br> <hr width=100% size=1><br> <span class=fs13><font face=tahoma><a href=http://www.bitsandbytesmalta.com/mailinglist/unsubscribe.php?email=$email> Please CLICK HERE if you wish to unsubscribe from our mailing list</a> <br><br>Your email address has not been given to any Third Parties.<br> The preceding is an email advertisement."; $message = wordwrap($message, 70); Quote Link to comment Share on other sites More sharing options...
skali Posted March 8, 2007 Share Posted March 8, 2007 Have you checked you spam folder as well? Sometimes it happens that the mails end up in spam box. Quote Link to comment Share on other sites More sharing options...
clintxp Posted March 8, 2007 Author Share Posted March 8, 2007 yes I checked the spam folder, but it's not the case. I will try the wordwrap function. thanks a lot, I will inform soon if it works or not Quote Link to comment Share on other sites More sharing options...
clintxp Posted March 8, 2007 Author Share Posted March 8, 2007 the problem was not solved with that command. I sent 10 emails and I received only 7 of them. Do you think there's something wrong with the server? The server is not mine, I am using a domain. thanks all of you Quote Link to comment Share on other sites More sharing options...
dhimok Posted March 8, 2007 Share Posted March 8, 2007 can u type the code that pulls the email addresses and sends the email to those emails? Quote Link to comment Share on other sites More sharing options...
clintxp Posted March 8, 2007 Author Share Posted March 8, 2007 Sure, here it is: $SQL = "select * from `emails` where `email` like 'clintxp@gmail.com'"; $retid = mysql_db_query($db, $SQL, $cid); if (!$retid) { echo( mysql_error()); } else { while ($row = mysql_fetch_array($retid)) { $email = $row['email']; $name = $row['name']; $status = $row["status"]; if (($name == "") or ($name == " ")) { $name = "Customer"; } $subject = "Special Offers from Bits & Bytes"; $message = " <html> </body> <span class=fs13>Dear $name<br><br> <img src=http://www.bitsandbytesmalta.com/mailinglist/picture.jpg border=0><br><br><br> <hr width=100% size=1><br> <span class=fs13><font face=tahoma><a href=http://www.bitsandbytesmalta.com/mailinglist/unsubscribe.php?email=$email> Please CLICK HERE if you wish to unsubscribe from our mailing list</a> <br><br>Your email address has not been given to any Third Parties.<br> The preceding is an email advertisement. "; $message = wordwrap($message, 70); $headers = 'From: Bits & Bytes Malta <mailinglist@bitsandbytesmalta.com>' . "\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; if (mail($email, $subject, $message, $headers)) { echo ("<center><span class=fs13><font face=tahoma color=black><br>$email</span></center>"); } else { echo ("<center><span class=fs13><font face=tahoma color=red><br>$email</span></center>"); } } } thanks Quote Link to comment Share on other sites More sharing options...
dhimok Posted March 8, 2007 Share Posted March 8, 2007 I would do it like this. First you pull the emails into an array, and add an other field in ur table that shows what users want to recieve email if u dont have that yet e.g. 'sendMeNewsletter' which can have values 0 = dont send me newsletter or 1 = send me newsletter. You can name that field whatever u want. // this pulls email addresses into an array $sql = mysql_query("SELECT * FROM emails WHERE sendMeNewsletter ='1') or die('Error, query failed. ' . mysql_error()); while($row = mysql_fetch_array($sql)) { $email[] = $row['email']; } // end email array then you will send the email to those who want it foreach($email as $key => $value) { $result = mysql_query("SELECT email, name FROM emails WHERE email = '$value'") or die('Error, query failed. ' . mysql_error()); list($email, $name) = @mysql_fetch_array($result); // headers $subject = "Special Offers from Bits & Bytes"; $no_reply = ' "Bits & Bytes Malta" <mailinglist@bitsandbytesmalta.com>'; $header = "Return-Path: $no_reply>\r\n"; $header .= "From: $no_reply\r\n"; $header .= "Content-Type: text/html; charset=iso-8859-1;\n\n\r\n"; // here you put ur email body and use html attachments and so on. Make sure to escape html attributes like <table width=\"70%\"></table> $body = "Hi $name<br /></br />"; // or u can call it $message. ur choice. I would call it body $body .="some text and html whatever images etc"; $body .="some text and html whatever images etc"; $body .="some text and html whatever images etc"; $body .="some text and html whatever images etc"; $body .="some text and html whatever images etc"; $body .="some text and html whatever images etc"; // end email body mail($value, $subject, $body, $header); } // end send email and you are done. Try this one. Hope it works for u Make sure u set the timeout longer in case u have like thousands of subscribers, otherwise u need to divide the emails in smaller ammounts. Quote Link to comment Share on other sites More sharing options...
dhimok Posted March 8, 2007 Share Posted March 8, 2007 You can also place the vars below outside the loop somewhere on top $subject = "Special Offers from Bits & Bytes"; $no_reply = ' "Bits & Bytes Malta" <mailinglist@bitsandbytesmalta.com>'; Quote Link to comment Share on other sites More sharing options...
clintxp Posted March 8, 2007 Author Share Posted March 8, 2007 thanks for your replies. I will try that. But how come sometimes it works and sometimes no? e.g. I run the script, i receive the email, i refresh the script, i receive, then i refresh again and receive nothing Quote Link to comment Share on other sites More sharing options...
clintxp Posted March 9, 2007 Author Share Posted March 9, 2007 I found that the problem was the php mail server provided by my domain. I tried everything on another domain and worked perfectly with my primary code thanks everyone for helping me out, I appreciate Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.