Link to home
Start Free TrialLog in
Avatar of dyarosh
dyarosh

asked on

Need to use FormMail to send email but need help formatting

I recently ported a website from one web host provider to another.  In doing so the group email function stopped working.  After receiving help from the experts here I finally discovered that I need to use FormMail to send the emails.  I am using NMS FormMail Version 3.14c1.  My problem now is that I don't know how to set it up so I can send to multiple receipients.  I have a form that the user chooses which group to send the email to.  The original code then would go out and read the email addresses from a database based on the members of the group.  The sending of the email was done right from the .ASP code.  Now that I have to use FormMail, I don't know how to set up the form to allow for multiple receipients.  Any help would be greatly appreciated.  I don't know Perl but I can get a reference book.
Avatar of ahoffmann
ahoffmann
Flag of Germany image

the user simply has to key in multiple adresses seperated by , (colon). That should do the trick.

But keep in mind that someone might use your script for mass-mailings .. take care.
Avatar of dyarosh
dyarosh

ASKER

The problem is the user simply selects a group from a list.  They don't have to key in the addresses at all.  The code then takes the list chosen and pulls out the emails from a database.  Now I can use a onsubmit function to pull out the addresses and create a string with the email addresses and set the recipient field in the form to the string but how do I handle the allow_mail_to in the MailForm.pl?
> ..  user simply selects a group from a list.
good solution (if you think secure too;-)

> .. takes the list chosen and pulls out the emails from a database.
this happens on your server in FormMail.cgi, so simply send the email to each of the "pulled" addresses.
Or do I miss something here?
Avatar of dyarosh

ASKER

Let me be more clear.  The form looks like this:

Group to send to: (pull down menu with the following options - All Members, Board, Activities, Music, plus many more)

Subject:

Message:


When the user selects Board for example, the original code went to the database and pulled out all members who belonged to the Board group and pulled their email ids.  It then used something like CDO to send the email after formatting the message.  I can't use CDO according to my web hosting provider.  I have to use FormMail.  So now that I have FormMail.pl in my cgi_bin directory I'm trying to get it to work with FormMail.  If I understand your comment, your saying I can access the database in the Perl script and pull out the emails there?  If that is correct can you give me a good website to look at for similar code examples or a good book to buy?  I do not know Perl.
could you please post the HTML code of the FORM
Avatar of dyarosh

ASKER

Here is the HTML code for the form.

<form action="../cgi_bin/FormMail.pl" method="POST" name="frmEmailGroup" >
 <input type="hidden" name="recipient" value="user@domain.tld" />
 <input type="hidden" name="email" value=<% Response.Write strSenderEmail %> />
 <input type="hidden" name="redirect" value="http://domain.tld/manage/emailGroup.asp" />

<table border="0" cellspacing="0" cellpadding="5">
 <tr align="left" valign="top" class="regTextBlack">
  <td><strong>Recipient Group :</strong></td>
  <td><select name="commRecipient" id="commRecipient" class="textEntryBox">
    <option value="-1"<% If  recipientGroup = "" or recipientGroup = -1 Then %> selected<% End If %>> Please Select a Group</option>
    <option value="0"<% If  recipientGroup = "0" Then %> selected<% End If %>>The Board</option>
    <option value="all"<% If  recipientGroup = "all" Then %> selected<% End If %>>All Members</option>
    <option value=""></option>
    <% For i = 0 to uBound(arrComm,2) %>
      <option value="<%= arrComm(0,i) %>"<% If recipientGroup = cStr(arrComm(0,i)) Then %> selected<% End If %>><%= arrComm(1,i) %></option>
    <% Next %>
   </select></td>
  </tr>
  <tr align="left" valign="top" class="regTextBlack">
   <td><strong>Subject :</strong> </td>
   <td><input name="subject" type="text" class="textEntryBox" value="<%=strSubject%>" size="39"></td>
  </tr>
  <tr align="left" valign="top" class="regTextBlack">
   <td><strong>Message :</strong> </td>
   <td><textarea name="Message" cols="38" rows="5" class="textEntryBox"><%=strMessage%></textarea></td>
  </tr>
  <tr align="left" valign="top" class="regTextBlack">
   <td>&nbsp;</td>
   <td><input name="sendEmail" type="submit" class="formInput" value="Send Email"></td>
  </tr>
 </table>
</form>      
as your commRecipient variable contains a name for an email group, you need to map this name in emailGroup.asp to the real email address, that's all
Avatar of dyarosh

ASKER

First thank you for changing my email and link.  Have been so frustrated with this problem I didn't even think about it when I posted the code.

I'm not sure I understand your comment about the commRecipient variable.  Do I take the commRecepient value and use an onsubmit function to pull out the email addresses and then map them to the recepient variable?  It is my understanding that the recepient variable controls who the email is sent to.
ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dyarosh

ASKER

The information you provided shows me how much I don't know.  My problem still isn't solved because it turns out that my web server prevents emails to other addresses not in its domain.  But at least now I know where the problem exists.  Thanks for your help.
> ..  my web server prevents emails to other addresses
well that's a mail server configuration problem, not one of your CGI usually