Jump to content

PHP email question -HTML- logging


jc624

Recommended Posts

Ok here's what I got:

<?php$msa = mysql_connect('server','id','pw') or die(mysql_error());@mysql_select_db('myDB');$getEmails = "SELECT id1, id2 FROM stores";$ansEmails = mysql_query($getEmails) or die(mysql_error());$emailToString = '';while($data = mysql_fetch_assoc($ansEmails)){   $emailToString .= " ".$data['id1']."";}$getArticle = "SELECT * FROM stores";$ansArticle = mysql_query($getArticle) or die(mysql_error());$article = mysql_fetch_assoc($ansArticle);mysql_free_result($ansEmails);mysql_free_result($ansArticle);$to = "youemail";$subj = "Test mail";$from = "From: myemail";$headers = "From: $from\r\n";$headers .= 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";$emailBodyString = "  <html>	<body><p>copy here</p>	</body>	   </html>";ini_set('SMTP', 'relay');ini_set("smtp_port", 80);mail($to, $subj, $emailBodyString, $from, $headers); echo "go get it!";?>

When I test it I just get it in text not html(so I get all the tags showing).....any ideas? Also I need to send this to a bunch of people if I wanted to make a log (succesful sents) how would you do that?Thanks!

Link to comment
Share on other sites

You have an error with the headers.$from = "From: myemail";$headers = "From: $from\r\n";After that $headers equals "From: From: myemail\r\n"
Wow justsomeguy your like the php guru :) Are you referring to do it like this:$to = "you@you.com";$subj = "Test mail";$headers = "From: me@me.com\r\n";$headers .= 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";Sorry can you kindly rephrase it. Thanks for your help!
Link to comment
Share on other sites

Thanks so much!!2 more questions:looks like everything is working just need to know:since I can't do Pear here (no answer why..) but I will try to do this the for loop like this:To loop will do this:

for ($x = 1; $x < 1500; $x++) {  $to = 'gc'.$x.'\@domain.com';}

The question I have is my data of 1500 if matching with the users email(making it easier to work on I believe) :EX:Row1:store_id is : 1email is: gc1@domain.com Row: 1450:store_id is: 1450 email is: gc1450@domain.com and so on...Don't I just do this:

$eMails = Array('gc'.store_id.'\@domain.com';);for ($x = 0; $x < count($eMails); $x++) {// code here}

Lastly is there a way to log them? I will keep checking the link you sent. Thanks!

Link to comment
Share on other sites

If you're sending to multiple email addresses they should be separated with a comma:user@example.com, anotheruser@example.comYou don't need to escape the @ character, it doesn't have a special meaning. I'm not sure what you're asking with the second question, but there is no way to determine if a user received an email or not, only if the mail server accepted the email for delivery.

Link to comment
Share on other sites

If you're sending to multiple email addresses they should be separated with a comma:user@example.com, anotheruser@example.comYou don't need to escape the @ character, it doesn't have a special meaning.
The thing is each data 1 - 1500 has its own data meaning customer gc400@domain.com will only get the 400 data(store_id and etc) only...thats why I did the 'store_id'.Thanks
Link to comment
Share on other sites

What's the "400 data"? Are you talking about sending the same email to 1500 people, or are you talking about sending a different email to 1500 different people?
Its the same email with different data like this:message will say:Your store ranked " . $article['rankdistrict'] . " in 2007.so the sql has 1500 entries with their store id(in one row first column) and rank(next column) and etc.
Link to comment
Share on other sites

OK, so it's 1500 different emails to 1500 different people. Write the code to send the email to one person, whoever the first person is. Make sure that code works, test it. Once it works, put it in a loop and replace the specific IDs and things with variables, like the iteration variable in the for loop, so that every user receives their own instead of just the one person.Regardless, this email script is going to take a really long time to run, you might need to increase the max execution time for the script. You're asking it to open 1500 socket connections to the mail server, so there's going to be a little bit of overhead for each connection.

Link to comment
Share on other sites

OK, so it's 1500 different emails to 1500 different people. Write the code to send the email to one person, whoever the first person is. Make sure that code works, test it. Once it works, put it in a loop and replace the specific IDs and things with variables, like the iteration variable in the for loop, so that every user receives their own instead of just the one person.Regardless, this email script is going to take a really long time to run, you might need to increase the max execution time for the script. You're asking it to open 1500 socket connections to the mail server, so there's going to be a little bit of overhead for each connection.
yeah the IS guy said its fine (since its internal and the server is only dedicated to our depatment)and yes I finally figure it out, I did the loop and its finally done :) $query = 'SELECT * FROM dbtablename'; if (!$sth = mysql_query($query)) { die("Can't Execute Query: ".mysql_error()); } while ($article = mysql_fetch_row($sth)) {}Thanks!
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...