473,498 Members | 2,026 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 2747
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($recipient,$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($recipient,$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
1726
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...
5
2608
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...
2
2203
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...
3
2208
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...
5
2416
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...
0
1757
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...
0
1490
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...
2
3726
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...
5
3569
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...
0
7121
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6993
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...
0
7197
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4584
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...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1411
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 ...
0
287
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...

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.