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
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], ...

Link to comment
Share on other sites

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.

Link to comment
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], ...

 

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.