Jump to content

Need some Direction with bulk mail.


Z33M@N

Recommended Posts

I want to know how can I get php to recognize [name] tags to insert the person name in a email where ever I put the tag.

 

What I do is I have a form with a textbox, inside the text box I type something like this:

 

Dear [name],

 

how are you to day?

 

--------------

 

Now that should show the person name that I'm calling from mysql.

 

How do I get php to do that?  :confused:

Link to comment
https://forums.phpfreaks.com/topic/197860-need-some-direction-with-bulk-mail/
Share on other sites

Can you try to explain it a little better. You mean you want to send out a bulk email to all the users of your system that if you type in [name] in the message it will replace that with each name of the users in your database? So that it will send out e-mails like this:

 

Dear Bob, ...

Dear Sam, ...

Dear Joe, ...

 

if you type in one email that goes

Dear [name], ...

If what I said earlier is the case then you need to do the following

 

1) Query the database for a result set on all users that will be receiving a mail

2) Create a while loop to handle the entire result set (Don't forget to check if result set is empty first as well as your while loop having a condition that uses either mysql_fetch_array or mysql_fetch_assoc to store in a temporary array like $row)

3) Put your message in a string variable

4) Do a str_replace on your message string like this:

str_replace("[name]",$row['username'],$messagestring);

5) Send the mail for each recipient inside the while loop

 

replace names of variables with appropriate names for your system.

Can you try to explain it a little better. You mean you want to send out a bulk email to all the users of your system that if you type in [name] in the message it will replace that with each name of the users in your database? So that it will send out e-mails like this:

 

Dear Bob, ...

Dear Sam, ...

Dear Joe, ...

 

if you type in one email that goes

Dear [name], ...

 

Hi there,

 

That is exactly what I'm looking for. I'm calling the names from the database, then those tags should somehow be converted to the names of each subscriber.

 

Thanks

If what I said earlier is the case then you need to do the following

 

1) Query the database for a result set on all users that will be receiving a mail

2) Create a while loop to handle the entire result set (Don't forget to check if result set is empty first as well as your while loop having a condition that uses either mysql_fetch_array or mysql_fetch_assoc to store in a temporary array like $row)

3) Put your message in a string variable

4) Do a str_replace on your message string like this:

str_replace("[name]",$row['username'],$messagestring);

5) Send the mail for each recipient inside the while loop

 

replace names of variables with appropriate names for your system.

 

Awesome this is exactly the thing I'm looking for.

 

Thanks for the help buddy  :D

 

If what I said earlier is the case then you need to do the following

 

1) Query the database for a result set on all users that will be receiving a mail

2) Create a while loop to handle the entire result set (Don't forget to check if result set is empty first as well as your while loop having a condition that uses either mysql_fetch_array or mysql_fetch_assoc to store in a temporary array like $row)

3) Put your message in a string variable

4) Do a str_replace on your message string like this:

str_replace("[name]",$row['username'],$messagestring);

5) Send the mail for each recipient inside the while loop

 

replace names of variables with appropriate names for your system.

 

Awesome this is exactly the thing I'm looking for.

 

Thanks for the help buddy  :D

 

No problemo. Good luck to ya. Please mark your thread as solved with the green button at the bottom.

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.