The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

2 Pages V < 1 2  
Reply to this topicStart new topic
> add multiple recipients to contact form
CharlesEF
post Jan 16 2014, 04:59 PM
Post #21


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



If your web host can't figure this out then you could re-write the code to parse the $your_email variable into an array and then use foreach to execute the mail command twice. I do not have much time right now but later tonight I can help with the code, if you want.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
justine
post Jan 16 2014, 05:00 PM
Post #22


Member
***

Group: Members
Posts: 54
Joined: 4-February 09
Member No.: 7,724



QUOTE(CharlesEF @ Jan 16 2014, 12:54 PM) *

QUOTE(justine @ Jan 16 2014, 11:16 AM) *

QUOTE(CharlesEF @ Jan 15 2014, 05:11 PM) *

QUOTE(justine @ Jan 15 2014, 04:29 PM) *

That is so very strange. Yes, I did get yours this afternoon. Thanks again!

In that case I'm out of ideas. I changed nothing and it works for me. Maybe you should contact your web host provider and see if there might be some kind of problem with your PHP setup. At least find out what version of PHP they are using. Maybe they need to update PHP?


Okay. I contacted the server, and below is what they told me. I am at a loss, though as to how to fix it. Any chance you could please advise? Thanks!!

The problem appears to be here in contact_form.php:
$your_email = "xx@cox.net,info@bb.com";

I would expect this to throw an error when multiple recipients are desired based off of how the script appears to be formatting the message. The code that calls the variable doesn’t appear to have any logic for parsing multiple recipients.

From the file code:
//If there is no error, send the email
if(!isset($hasError)) {

$emailTo = $your_email; //  there is nothing to verify that this is correctly formatted, causing your issue.
$subject = 'Contact Form Submission from '.$name;

//message body
$body ="Name: $name \n\n";
$body .="Email: $email \n\n";
if(isset($phone)) $body .="Phone:$phone\n\n";
if(isset($company_name)) $body .="Company Name:$company_name\n\n";
if(isset($company_url)) $body .="Company Url:$company_url \n\n";
$body .="Message: $comments";


$headers = 'From: '.$your_web_site_name.' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;

mail($emailTo, $subject, $body, $headers);

When the variable value is expanded from $emailTo, the lack of a properly formatted SINGLE email address causes the error.

This is not a php/server configuration issue.

As far as I understand the mail command there is no parsing to do in the php script. The mail command itself does the parsing. You just need to be sure the email addresses are formatted correctly (and are valid - of cource). I placed your contactus and php script on my website, it works fine as is. For this reason I think your support person got it wrong. Point them to the mail manual found here. Did you tell them that someone else can run your php script and do get 2 emails?


Hi, This is what the support guy says. any thoughts? Thx!!
Here is the part of the reference manual he linked to that suggests the configuration needs attention:

to
Receiver, or receivers of the mail.
The formatting of this string must comply with » RFC 2822. Some examples are:
• user@example.com
• user@example.com, anotheruser@example.com
• User <user@example.com>
• User <user@example.com>, Another User <anotheruser@example.com>
Your configuration does not have the proper formatting.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Jan 16 2014, 05:19 PM
Post #23


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



QUOTE(justine @ Jan 16 2014, 04:00 PM) *

Hi, This is what the support guy says. any thoughts? Thx!!
Here is the part of the reference manual he linked to that suggests the configuration needs attention:

to
Receiver, or receivers of the mail.
The formatting of this string must comply with » RFC 2822. Some examples are:
• user@example.com
• user@example.com, anotheruser@example.com
• User <user@example.com>
• User <user@example.com>, Another User <anotheruser@example.com>
Your configuration does not have the proper formatting.

To be honest I have no idea what that guy is talking about. If you look at the 2nd example above it is exactly like your php script (except for the space - the PHP manual shows no space). I will download your files again and do another test but I would not hold my breath.

BTW, what program do you use to edit HTML/PHP files?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
justine
post Jan 16 2014, 05:28 PM
Post #24


Member
***

Group: Members
Posts: 54
Joined: 4-February 09
Member No.: 7,724



QUOTE(CharlesEF @ Jan 16 2014, 04:19 PM) *

QUOTE(justine @ Jan 16 2014, 04:00 PM) *

Hi, This is what the support guy says. any thoughts? Thx!!
Here is the part of the reference manual he linked to that suggests the configuration needs attention:

to
Receiver, or receivers of the mail.
The formatting of this string must comply with » RFC 2822. Some examples are:
• user@example.com
• user@example.com, anotheruser@example.com
• User <user@example.com>
• User <user@example.com>, Another User <anotheruser@example.com>
Your configuration does not have the proper formatting.

To be honest I have no idea what that guy is talking about. If you look at the 2nd example above it is exactly like your php script (except for the space - the PHP manual shows no space). I will download your files again and do another test but I would not hold my breath.

BTW, what program do you use to edit HTML/PHP files?


Coffee Cup. Thx again!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Jan 16 2014, 05:35 PM
Post #25


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



QUOTE(justine @ Jan 16 2014, 04:28 PM) *

QUOTE(CharlesEF @ Jan 16 2014, 04:19 PM) *

BTW, what program do you use to edit HTML/PHP files?

Coffee Cup. Thx again!

I do not know that program. The reason I asked it that some programs insert a BOM (byte-order mark) which can cause problems. I have just sent you another test email. I did not open the files at all this time so let me know if you get 2 emails.

If you want to test for yourself click here.

This post has been edited by CharlesEF: Jan 16 2014, 05:36 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
justine
post Jan 16 2014, 05:38 PM
Post #26


Member
***

Group: Members
Posts: 54
Joined: 4-February 09
Member No.: 7,724



QUOTE(CharlesEF @ Jan 16 2014, 04:35 PM) *

QUOTE(justine @ Jan 16 2014, 04:28 PM) *

QUOTE(CharlesEF @ Jan 16 2014, 04:19 PM) *

BTW, what program do you use to edit HTML/PHP files?

Coffee Cup. Thx again!

I do not know that program. The reason I asked it that some programs insert a BOM (byte-order mark) which can cause problems. I have just sent you another test email. I did not open the files at all this time so let me know if you get 2 emails.

If you want to test for yourself click here.


Ok. So I got your tests, and I went to your link and sent them to myself, and I got them, too. What oh what can I do to fix this on my end? I might be losing my mind! smile.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Jan 16 2014, 05:56 PM
Post #27


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



QUOTE(justine @ Jan 16 2014, 04:38 PM) *

QUOTE(CharlesEF @ Jan 16 2014, 04:35 PM) *

QUOTE(justine @ Jan 16 2014, 04:28 PM) *

QUOTE(CharlesEF @ Jan 16 2014, 04:19 PM) *

BTW, what program do you use to edit HTML/PHP files?

Coffee Cup. Thx again!

I do not know that program. The reason I asked it that some programs insert a BOM (byte-order mark) which can cause problems. I have just sent you another test email. I did not open the files at all this time so let me know if you get 2 emails.

If you want to test for yourself click here.


Ok. So I got your tests, and I went to your link and sent them to myself, and I got them, too. What oh what can I do to fix this on my end? I might be losing my mind! smile.gif

I still say that support person is wrong but I doubt you will be able to change his mind (sad to say but true sometimes).

Also, I forgot to mention this before, your contactus.html file contains many errors (I did not change anything and the form still works). The validator found on this site and the validator found at the W3C site report different errors. Mainly, it looks like you are using HTML5 as a doctype but you are using XHTML closing '/' tags on a lot of elements.

I guess your only other options is to execute the mail command twice, once for each email address. If you want to tackle this yourself then I will give you 2 hints, explode and foreach commands. Post back with any questions.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
justine
post Jan 16 2014, 07:06 PM
Post #28


Member
***

Group: Members
Posts: 54
Joined: 4-February 09
Member No.: 7,724



QUOTE(CharlesEF @ Jan 16 2014, 04:56 PM) *

QUOTE(justine @ Jan 16 2014, 04:38 PM) *

QUOTE(CharlesEF @ Jan 16 2014, 04:35 PM) *

QUOTE(justine @ Jan 16 2014, 04:28 PM) *

QUOTE(CharlesEF @ Jan 16 2014, 04:19 PM) *

BTW, what program do you use to edit HTML/PHP files?

Coffee Cup. Thx again!

I do not know that program. The reason I asked it that some programs insert a BOM (byte-order mark) which can cause problems. I have just sent you another test email. I did not open the files at all this time so let me know if you get 2 emails.

If you want to test for yourself click here.


Ok. So I got your tests, and I went to your link and sent them to myself, and I got them, too. What oh what can I do to fix this on my end? I might be losing my mind! smile.gif

I still say that support person is wrong but I doubt you will be able to change his mind (sad to say but true sometimes).

Also, I forgot to mention this before, your contactus.html file contains many errors (I did not change anything and the form still works). The validator found on this site and the validator found at the W3C site report different errors. Mainly, it looks like you are using HTML5 as a doctype but you are using XHTML closing '/' tags on a lot of elements.

I guess your only other options is to execute the mail command twice, once for each email address. If you want to tackle this yourself then I will give you 2 hints, explode and foreach commands. Post back with any questions.


Thank you. The W3C validator reports all those errors with the Google maps. Is there a way around that? I'll use the validator here, too. Also, as for how to execute the mail command twice, I am at a complete loss. I am afraid I've reached my knowledge of php forms. Thx for all your help!



User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Jan 16 2014, 07:54 PM
Post #29


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



QUOTE(justine @ Jan 16 2014, 06:06 PM) *

Thank you. The W3C validator reports all those errors with the Google maps. Is there a way around that? I'll use the validator here, too. Also, as for how to execute the mail command twice, I am at a complete loss. I am afraid I've reached my knowledge of php forms. Thx for all your help!

Attached is a modified 'contact_form.php' file. I commented out some code and inserted some other commands. If you want to learn then this is what I did.

CODE
I commented out this line of code: $emailTo = $your_email;

I then changed the mail logic like so:
$emails = explode(',', $your_email);
foreach($emails as $emailTo)
{
    $headers = 'From: '.$your_web_site_name.' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;
    mail($emailTo, $subject, $body, $headers);
    sleep(2);
}

I had to put a little delay in because 4 out of 5 were received without the delay. With the delay all were received. This means after you click 'Send' you will have to wait a few seconds before the thank you page appears. Also, there MUST not be any space after the comma in your $your_email variable. You can add more email addresses in the future if you want but remember that each email address will cause a 2 second delay. Maybe you can change the value to 1 if you want to try that.

If this works for you then let's finish this thread and you can start a new thread with your validation problems.

Let me know how it works for you.

Attached File  contact_form.php ( 2.5k ) Number of downloads: 361


This post has been edited by CharlesEF: Jan 16 2014, 07:57 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
justine
post Jan 16 2014, 08:39 PM
Post #30


Member
***

Group: Members
Posts: 54
Joined: 4-February 09
Member No.: 7,724



QUOTE(CharlesEF @ Jan 16 2014, 06:54 PM) *

QUOTE(justine @ Jan 16 2014, 06:06 PM) *

Thank you. The W3C validator reports all those errors with the Google maps. Is there a way around that? I'll use the validator here, too. Also, as for how to execute the mail command twice, I am at a complete loss. I am afraid I've reached my knowledge of php forms. Thx for all your help!

Attached is a modified 'contact_form.php' file. I commented out some code and inserted some other commands. If you want to learn then this is what I did.

CODE
I commented out this line of code: $emailTo = $your_email;

I then changed the mail logic like so:
$emails = explode(',', $your_email);
foreach($emails as $emailTo)
{
    $headers = 'From: '.$your_web_site_name.' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;
    mail($emailTo, $subject, $body, $headers);
    sleep(2);
}

I had to put a little delay in because 4 out of 5 were received without the delay. With the delay all were received. This means after you click 'Send' you will have to wait a few seconds before the thank you page appears. Also, there MUST not be any space after the comma in your $your_email variable. You can add more email addresses in the future if you want but remember that each email address will cause a 2 second delay. Maybe you can change the value to 1 if you want to try that.

If this works for you then let's finish this thread and you can start a new thread with your validation problems.

Let me know how it works for you.

Attached File  contact_form.php ( 2.5k ) Number of downloads: 361



Perfect. Thank you SO much! Have a great weekend.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Jan 16 2014, 08:49 PM
Post #31


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



QUOTE(justine @ Jan 16 2014, 07:39 PM) *

Perfect. Thank you SO much! Have a great weekend.

Glad it finally worked for you. I still think it should have worked the way it was because it works for me. Did you ever find out what version of PHP your server is running?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Frederiek
post Jan 17 2014, 05:17 AM
Post #32


Programming Fanatic
********

Group: Members
Posts: 5,146
Joined: 23-August 06
From: Europe
Member No.: 9



QUOTE
Also, I forgot to mention this before, your contactus.html file contains many errors (I did not change anything and the form still works). The validator found on this site and the validator found at the W3C site report different errors. Mainly, it looks like you are using HTML5 as a doctype but you are using XHTML closing '/' tags on a lot of elements.

FYI, you can use XHTML closing syntax for empty elements in HTML5.
And the WDG validator doesn't validate HTML5.
But it is best to fix the errors you have.

So, mainly, you have a stray </li>, ampersands in URIs need to be character encoded (see http://www.htmlhelp.com/tools/validator/problems.html ), your IDs need to be unique on each page and label for doesn't point to phone.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Jan 17 2014, 05:20 AM
Post #33


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



QUOTE(Frederiek @ Jan 17 2014, 04:17 AM) *

QUOTE
Also, I forgot to mention this before, your contactus.html file contains many errors (I did not change anything and the form still works). The validator found on this site and the validator found at the W3C site report different errors. Mainly, it looks like you are using HTML5 as a doctype but you are using XHTML closing '/' tags on a lot of elements.

FYI, you can use XHTML closing syntax for empty elements in HTML5.
And the WDG validator doesn't validate HTML5.
But it is best to fix the errors you have.

So, mainly, you have a stray </li>, ampersands in URIs need to be character encoded (see http://www.htmlhelp.com/tools/validator/problems.html ), your IDs need to be unique on each page and label for doesn't point to phone.

Yes, the W3C validator did report the closing tag '/' problem. The WDG validator made no mention of it.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Frederiek
post Jan 17 2014, 11:48 AM
Post #34


Programming Fanatic
********

Group: Members
Posts: 5,146
Joined: 23-August 06
From: Europe
Member No.: 9



No, it didn't. It seemed like that, but in fact it choked on the duplicate ID email.
Besides, the online page doesn't seem to use the "/" closing syntax. The posted file at post #13 does.

The WDG validator starts by indicating that the Level of HTML (or in other words: the DOCTYPE) is Unknown. Like I said, the WDG validator doesn't validate HTML5, only earlier flavours of (X)HTML.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Jan 17 2014, 02:59 PM
Post #35


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



QUOTE(Frederiek @ Jan 17 2014, 10:48 AM) *

No, it didn't. It seemed like that, but in fact it choked on the duplicate ID email.
Besides, the online page doesn't seem to use the "/" closing syntax. The posted file at post #13 does.

The WDG validator starts by indicating that the Level of HTML (or in other words: the DOCTYPE) is Unknown. Like I said, the WDG validator doesn't validate HTML5, only earlier flavours of (X)HTML.

You are correct, I forget that the WDG validator stopped after 'x' errors. And, now I do remember the WDG validator stating it does not do HTML5 (something like that).


Thank you
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

2 Pages V < 1 2
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 26th April 2024 - 03:38 AM