Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

Need help with Formmail modification

formmail carbon copy modification

10:30 pm on Oct 17, 2009 (gmt 0)

5+ Year Member


I have been a long time user of NMS FormMail (a popular drop in replacement for Matts original script).

For the first time, however, I am in desparate need of the ability to Carbon Copy other folks as selected by a drop down menu and/or checkbox array.

There is no provision in the script to do this, for fear of abuse, which of course makes sense, except that I have limited the recipient field to only those domains that are allowed to receive the form data.

My exact application is this, a user fills out a request for information. The form directs to a "recipient_alias" which is a simple email Forwarder, that forwards the information request form to 3 of my vendors, who respond to the client with their pricing.

However, the user (often an end client, sometimes a sales rep) needs to be able to select from a drop down or check box array, to Carbon Copy one or more of the sales reps, depending upon the product information desired.

I am pretty sure I'd have no problem setting up the form fields, but... NMS Form Mail v3.14 (latest and final) does not support "CC".

I am hoping that someone who is perl savvy could give me a line of code to insert as a solution.

As a reference, there was nearly the exact same post AND solution back in 2006, at this link:

HOWEVER.... the solution proposed was for Matts original script. I can't locate a similar place to insert the code snippet, in the final NMS replacement version.

Thanks very much, in advance, for any light shed!

8:33 am on Oct 21, 2009 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member

I'm not familiar with NMS formmail (and they might differ from version to version), can you tell me which version you are using?
depending on the configuration, if they are using the sendmail program (or a drop in replacement), look for "/sendmail" in the code (should be something like
open(SENDMAIL, "¦/usr/sbin/sendmail -t")
and you'll be close to the solution. If they use smtp to send the email, it'll be different. For that, I'd have to look at the script, which I'm happy to do if you tell me which version you're running and paste the changes you've made to the script.
11:19 am on Oct 21, 2009 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

you should go through the code and look at everywhere that the word "recipient" or "recipients" occurs and understand why it is doing all the hiding and checking of email addresses.
to implement CC: capability, repeat everything you have seen for "recipient_cc".
you really want to avoid someone using your script and sendmail service to distribute spam.
12:27 am on Oct 22, 2009 (gmt 0)

5+ Year Member

Hello and thank you for your replies. Please note that I am using NMS FormMail Version 3.14.c1 which I believe was the final release of this script.

The word "sendmail" appears in many places in the script, and the word "recipient" appears in twice as many.

I can post the script here if that does not violate the forum rules. Since I am not a programmer, it would great if a line or two of code could be dropped in with a little instruction.

Thanks in advance for any help!

6:15 am on Oct 22, 2009 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

please don't post the script in the forum!
anybody who wants it can find it easily.

yes - there are easy ways to do what you want.
i would not recommend using them.

if you put bare email addresses in a selection element of the form it will be scraped and the mailbox owner will be spammed.
also, if you don't properly validate your form input the script will be abused by spammers to send email using your cc: list vulnerability.
the nms formmail script is designed to limit your exposure to these issues.
doing it right is not one or two lines of code.

11:31 am on Oct 22, 2009 (gmt 0)

5+ Year Member

Good morning and thanks for your reply.

I agree and understand about not putting email addresses directly in the form code, which is why I use the "recipient_alias" feature of Formmail to prevent that.

I also agree and understand about validating the recipients within the script, which is why I use the following settings within the code:

a) limit the number of total recipients to 5 (the 3 vendors, myself and the sales rep) ...the sales rep being the part i need help with

b) limit the domain allowed to send from, to my domain only

I recognize that unscrupulous spammers may find a way around these validations, and I am willing to put in any other possible validations that may be necessary, to gain the advantage of being able to CC the specific agent for that account. I just don't know how.

I would be most appreciative of any assistance in this regard.


11:20 am on Oct 23, 2009 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member

If I saw that correctly, you could just manipulate @recipients and push the extra-rcpts that you want to cc. give that a try.
4:19 pm on Oct 23, 2009 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

yes - it would be a simpler solution if you don't specifically require those to be CC: vs To: recipients
11:22 pm on Oct 28, 2009 (gmt 0)

5+ Year Member

Therein lies the rub, as they say.

I would be perfectly fine having those sales reps be 'recipients' (TO) instead of (CC)... however... I need to be able to have the sender choose which sales rep to send to.

Formmail allows the use of one alias, so for example, I have it set as follows.

myalias = email@mydomain.com where email@mydomain.com is a forwarder to vendor1@vendor1.com,vendor2@vendor2.com and me@mydomain.com

If I have 6 sales reps how do I have a drop down or checkbox system so that rep is also a "TO" recipient, as suggested. As you can see, I cant just add them to the forwarder, or all sales reps would get all emails.

Thanks again for your interest and assistance.

1:26 pm on Oct 29, 2009 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

make a hash of aliases and their email address(es):
%recipient_alias = (
'joe' => 'joe@example.com',
'tom' => 'tom@example.com,tom@home.com',
'rob' => 'rob@example.com',
'pete' => 'pete@example.com',
'matt' => 'matt@example.com',
'john' => 'john@example.com'

the selection/radio form input element should use name="recipient" and value="alias".
i haven't looked to see if that script would support multiple selections.

12:00 am on Oct 30, 2009 (gmt 0)

5+ Year Member

The script allows for the setup as you show above, and in fact, the very first thing I tried, was exactly what you are showing in the example.

The problem is the script won't allow more than one alias to be selected (the first main alias to hit the vendors, and the second alias for the reps).

However, you did just give me an idea... a bit of a round-a-bout but I think it will do the job.

I will drop the HIDDEN Recipient alias altogether, and instead ...make the same group of aliases as you show, but EACH one will go to its own unique Forwarder. Then, EACH Forwarder would include only that rep PLUS, the various vendors.

I ***think*** that should achieve the desired result, do you concur? I will also post the result, in case a future poster needs to know as I did.


10:10 pm on Oct 31, 2009 (gmt 0)

5+ Year Member

Just a quick update. What I described in my last post did not work. Albeit I was a bit bleary eyed so I'm going to start from scratch again tonite and see if I can get it working.
1:01 am on Nov 2, 2009 (gmt 0)

5+ Year Member

Final update. After tweaking out a few syntax errors, this solution DOES achieve the desired result. Thanks for letting me use your forum to work this out.