PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
New to PHP coding so sorry if this is a stupid question.
I have a form on my web site (send.php), which sends me an E-Mail with the form information.
I would like to send the information to two E-Mail address's instead of one. Can someone help
with syntax in the $to= line please.
Thanks Ed
This works:-
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
EddyStone wrote:New to PHP coding so sorry if this is a stupid question.
I have a form on my web site (send.php), which sends me an E-Mail with the form information.
I would like to send the information to two E-Mail address's instead of one. Can someone help
with syntax in the $to= line please.
Another option would be to use an array for multiple email addresses.
Oran
Your idea looks to be the easiest. Tried that but the mail only seems to go to the first E-Mail address in the
$to line. I take it there should be a space after the comma seperating the E-Mail address's?
aerodromoi
Thanks seems like a good ide but still not sure how to get the code into my example.
I am also having trouble with spammers entering just anything into the form, I pressume to see if its a working link, the form info
comes through OK in those cases but with assorted dummy information in the fields.
Well, you can put a space after the comma and you can get rid of this space... it doesn't matter.
Why it's not working? I don't know, we need to see the content of sendmail.php.
I also checked with your form, and found out that it'd send the message without even making sure that the fields are not empty.
Oran
Your idea looks to be the easiest. Tried that but the mail only seems to go to the first E-Mail address in the
$to line. I take it there should be a space after the comma seperating the E-Mail address's?
aerodromoi
Thanks seems like a good ide but still not sure how to get the code into my example.
I am also having trouble with spammers entering just anything into the form, I pressume to see if its a working link, the form info
comes through OK in those cases but with assorted dummy information in the fields.
Read the PHP manual on mail(). There are some differences in the way Windows servers handle mail and *nix servers do it when it comes to the to address. Make sure you know your server type and code for that.
PS I ran into this myself once when I moved from a Linux box to a Windows box. The problem was the way that Windows server handles the "User Name" <user@email.com> syntax.
Exactly as Feyd said. When you place the var in double quotes, PHP takes the string and tries to parse the string for vars. If you just throw the var to PHP, it won't do that. It is a matter of efficiency and clean coding, in my opinion.
To help stop SPAM would it be possible to ask a question at the bottom of the form e.g what is sum of two random numbers
and only proceed if the sum is correct, or I am I being just too simplistic?
Thanks Ed
Those can help. The code above is vulnerable to header injection however, thus making it a great script to spam people from. The vulnerability is centered around $Name.
I'm still wondering if it would not be easier, and safer, to use a mailing library built to understand these pitfalls. I linked to the too most recommended earlier.