473,616 Members | 2,973 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sending multiple emails from a form

9 New Member
I am setting up a user request form to help our IT staff get all of the information required to setup a user account, I would like to send the form to a static address each time that it is submitted but I would also like to send it to whomever is submitting the form. It currently will submit to the static address with no problems but I can't seem to figure out how to cc or send directly to multiple addresses. I won't include the form code, just what I think is relevant here. Thanks in advance

Expand|Select|Wrap|Line Numbers
  1.   <?php 
  2.     ini_set("SMTP","mymailserver.com");
  3.     ini_set("sendmail_from","UserRequest@mymailserver.com");
  4.    if ($_SERVER['REQUEST_METHOD'] != 'POST'){
  5.          $me = $_SERVER['PHP_SELF'];
  6.  
  7. ?>
  8. </div>
  9. <form method="post" name="form1" id="form1" action="<?=$me?>">
  10.     <div align="center">
  11.  <?
  12. $name = $_POST['name'];
  13. $position = $_POST["position"];
  14. $location = $_POST["location"];
  15. $department = $_POST["department"];
  16. $user_phone = $_POST["user_phone"];
  17. $user_email = $_POST["user_email"];
  18. $manager = $_POST["manager"];
  19. $manager_phone = $_POST["manager_phone"];
  20. $manager_email = $_POST["manager_email"];
  21. $time_zone = $_POST["time_zone"];
  22. $start_date = $_POST["start_date"];
  23. $printer = $_POST["printer"];
  24. $request_type = $_POST["request_type"];
  25. $access_type_11 = $_POST["access_type_11"];
  26. $access_type_12 = $_POST["access_type_12"];
  27. $access_type_13 = $_POST["access_type_13"];
  28. $access_type_14 = $_POST["access_type_14"];
  29. $access_type_15 = $_POST["access_type_15"];
  30. $access_type_16 = $_POST["access_type_16"];
  31. $model_after_user1 = $_POST["model_after_user1"];
  32. $model_after_11 = $_POST["model_after_11"];
  33. $model_after_12 = $_POST["model_after_12"];
  34. $model_after_13 = $_POST["model_after_13"];
  35. $model_after_14 = $_POST["model_after_14"];
  36. $model_after_15 = $_POST["model_after_15"];
  37. $model_after_user2 = $_POST["model_after_user2"];
  38. $model_after_21 = $_POST["model_after_21"];
  39. $model_after_22 = $_POST["model_after_22"];
  40. $model_after_23 = $_POST["model_after_23"];
  41. $model_after_24 = $_POST["model_after_24"];
  42. $model_after_25 = $_POST["model_after_25"];
  43. $notes = $_POST["notes"];
  44. ?> 
  45.  
Expand|Select|Wrap|Line Numbers
  1.   <?php
  2.    } else {
  3.       error_reporting(0);
  4.       $errors = array();
  5.       if (!$_POST['name'])
  6.          $errors[] = "Name is required";
  7.       if (count($errors)>0) {
  8.          foreach($errors as $err)
  9.             echo "$err<br>\n";
  10.          echo "<br>Please use your browser's Back button to fix.";
  11.       } else {
  12.          $recipient = 'bcanter@mymailserver.com';
  13.          $from = "My Company";
  14.          $subject = "User Request";
  15.          $msg = "Message sent by $from\n";
  16.          $msg.="\nName: ".$_POST['name'];
  17.          $msg.="\nPosition: ".$_POST['position'];
  18.          $msg.="\nLocation: ".$_POST['location'];
  19.          $msg.="\nDepartment: ".$_POST['department'];
  20.          $msg.="\nUser's Phone: ".$_POST['user_phone'];
  21.          $msg.="\nUser's E-mail: ".$_POST['user_email'];
  22.          $msg.="\nManager: ".$_POST['manager'];
  23.          $msg.="\nManager's Phone: ".$_POST['manager_phone'];
  24.          $msg.="\nManager's Email: ".$_POST['manager_email'];
  25.          $msg.="\nTime Zone: ".$_POST['time_zone'];
  26.          $msg.="\nStart Date: ".$_POST['start_date'];
  27.          $msg.="\nPrinter: ".$_POST['printer'];
  28.          $msg.="\nRequest Type: ".$_POST['request_type'];
  29.          $msg.="\nPosition: ".$_POST['position'];
  30.          $msg.="\nAccess Type: ".$_POST['access_type_11'];
  31.          $msg.="\nAccess Type: ".$_POST['access_type_12'];
  32.          $msg.="\nAccess Type: ".$_POST['access_type_13'];
  33.          $msg.="\nAccess Type: ".$_POST['access_type_14'];
  34.          $msg.="\nAccess Type: ".$_POST['access_type_15'];
  35.          $msg.="\nAccess Type: ".$_POST['access_type_16'];
  36.          $msg.="\nModel After User1: ".$_POST['model_after_user1'];
  37.          $msg.="\nModel After 1: ".$_POST['model_after_11'];
  38.          $msg.="\nModel After 1: ".$_POST['model_after_12'];
  39.          $msg.="\nModel After 1: ".$_POST['model_after_13'];
  40.          $msg.="\nModel After 1: ".$_POST['model_after_14'];
  41.          $msg.="\nModel After 1: ".$_POST['model_after_15'];
  42.          $msg.="\nModel After User2: ".$_POST['model_after_user2'];
  43.          $msg.="\nModel After 2: ".$_POST['model_after_21'];
  44.          $msg.="\nModel After 2: ".$_POST['model_after_22'];
  45.          $msg.="\nModel After 2: ".$_POST['model_after_23'];
  46.          $msg.="\nModel After 2: ".$_POST['model_after_24'];
  47.          $msg.="\nModel After 2: ".$_POST['model_after_25'];
  48.          $msg.="\nNotes: ".$_POST['notes'];
  49.            if (mail($recipient,$subject,$msg)){
  50.             echo "<p>Your request has been sent</p>";
  51.             echo nl2br($msg);
  52.          } else
  53.             echo "An unexpected error has occured";
  54.       }
  55.    }
  56. ?>
  57.  
What do I need to add to send mail to $manager_email and still get it sent to the static address?
Jul 23 '07 #1
3 2760
mwasif
802 Recognized Expert Contributor
You can mention multiple emails separated by comma in to. You have to pass additional parameter of headers if you want to send mail as Cc or Bcc. .e.g

[PHP]$headers = 'Cc: another@address .com' . "\r\n";
$headers.= 'Bcc: example@example .com' . "\r\n";

if (mail($recipien t,$subject,$msg , $headers)){
echo "<p>Your request has been sent</p>";
echo nl2br($msg);
} else
echo "An unexpected error has occured";[/PHP]
Checkout the PHP manaul for detailed information about mail().
Jul 23 '07 #2
bcanter
9 New Member
You can mention multiple emails separated by comma in to. You have to pass additional parameter of headers if you want to send mail as Cc or Bcc. .e.g

[PHP]$headers = 'Cc: another@address .com' . "\r\n";
$headers.= 'Bcc: example@example .com' . "\r\n";

if (mail($recipien t,$subject,$msg , $headers)){
echo "<p>Your request has been sent</p>";
echo nl2br($msg);
} else
echo "An unexpected error has occured";[/PHP]
Checkout the PHP manaul for detailed information about mail().
I'm not sure what I was doing wrong but I used this and I couldn't get the variable to work with the CC address, I did use the static address here and used the variable as the main recipient and it works fine. Issue closed, thanks.
Jul 23 '07 #3
kovik
1,044 Recognized Expert Top Contributor
Swiftmailer has support for sending multiple emails as well, and very simply too.
Jul 23 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1746
by: Thomas Mandelid | last post by:
A client I`m working for want to be able to send multiple emails to customers of their own. I have developed a simple app to accomplish this, but the application has a few flaws and I`m looking for some help/advice. The current setup is like this: - Read emails from db - Send a mail to each address in a foreach This generates a lot of trafic and load on the server.
5
2622
by: BaWork | last post by:
I have a web form where a client can select which site members to send an email to. This form is populated from the contents of the member table, so the form can have 0-x names listed on it depending on member expiration dates. When the form is submitted, the code loops through the form contents and sends an email to those members that meet the selected criteria. All this worked perfectly when I was sending text emails, but since I
2
2219
by: kimberly.shaffer | last post by:
Okay, I can automate sending of multiple emails with records using Groupwise and Access DB. But now what I need to do is send multiple fields associated with one field out automatically and can't figure out how to do it. For instance, my records look like this: strEmail strGroup jjohns@comcast.net catlovers jjohns@comcast.net doglovers
3
2220
by: VB Programmer | last post by:
My company has it's own webserver, which is going to host our ASP.NET web application. We want the website to be able to send out emails. 1. What do I need on the server so that it has the abillity to send out emails? It is a Windows 2000 Professional SP3 server. 2. Any examples (code, etc...) on how to send out emails via an ASP.NET webform? Thanks!
5
2435
by: Jai | last post by:
Hi, I am in a problem of sending mass emails(newsletter) to my website members. Actually my problem is this: I want to send newsletter to my website members. But I had given a facility for each member to choose different category of products or all products newsletter.
0
1772
by: damimkader | last post by:
Hi, I'm trying to send emails using a Macro based on an Excel Sheet and the Email Client I'm using is Lotus Notes. OS used - Windows Xp. Language - VB Below is the Code I'm using for doing the same. Dim Maildb As Object
0
1498
by: ramab | last post by:
hi, i'm a bit stuck here in sending emails to multiple users which i need to read from a database. With codes below, i able only to send 2 recipients. any idea how to send to multiple users? thx strSubject = "Test Memo sent at" & Now() strDest = "email" strCopy = "copy_email"
2
3745
by: lstanikmas | last post by:
Hi, I'm validating a form with this ASP but receiving some blank email responses; does anyone see anything wrong with it?: function isFormVarExcluded(thisForm, strToCheck) { var strExcludeVars = thisForm.elements.value; var arrExcludeVars = strExcludeVars.split(","); for (var j=0; j<arrExcludeVars.length; j++) { if (arrExcludeVars == strToCheck) return true;
5
3584
by: wktarin | last post by:
Hi. I'm a relative newcomer to the world of php, and I keep bumping into a problem with a mail () form. I need to send an automatic email to two addresses, but I can't seem to get it to work. One email address works just fine, but I can't get the email sent to two different addresses no matter what I try. Below is my code. If someone could help me spot my errors, I'd appreciate it. Thanks! Code from actual page: <?php //Check if the form...
0
8146
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8647
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6097
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4141
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2579
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1445
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.