473,513 Members | 2,391 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Add second recipient to email

229 New Member
Hi, I have this php email code that works fine but I want to add a second recipient to emails. I tried adding it here but it didnt work

"CONTACT_FORM", 'contact@mysite.co.uk' , 'secondemail@hotmail.com'


Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. // Where will you get the forms' results?
  4. define("CONTACT_FORM", 'contact@mysite.co.uk');
  5. ?>
  6.  
  7.  
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. include dirname(dirname(__FILE__)).'/mail.php';
  4.  
  5. error_reporting (E_ALL ^ E_NOTICE);
  6.  
  7. $post = (!empty($_POST)) ? true : false;
  8.  
  9. if($post)
  10. {
  11. include 'email_validation.php';
  12.  
  13. $name = stripslashes($_POST['name']);
  14. $email = trim($_POST['email']);
  15. $subject = stripslashes($_POST['subject']);
  16. $message = stripslashes($_POST['message']);
  17.  
  18.  
  19. $error = '';
  20.  
  21. // Check name
  22.  
  23. if(!$name)
  24. {
  25. $error .= 'Please enter your name.<br />';
  26. }
  27.  
  28. // Check email
  29.  
  30. if(!$email)
  31. {
  32. $error .= 'Please enter an e-mail address.<br />';
  33. }
  34.  
  35. if($email && !ValidateEmail($email))
  36. {
  37. $error .= 'Please enter a valid e-mail address.<br />';
  38. }
  39.  
  40. // Check message (length)
  41.  
  42. if(!$message || strlen($message) < 10)
  43. {
  44. $error .= "Please enter your message. It should have at least 10 characters.<br />";
  45. }
  46.  
  47.  
  48. if(!$error)
  49. {
  50. $mail = mail(CONTACT_FORM, $subject, $message,
  51.      "From: ".$name." <".$email.">\r\n"
  52.     ."Reply-To: ".$email."\r\n"
  53.     ."X-Mailer: PHP/" . phpversion());
  54.  
  55.  
  56. if($mail)
  57. {
  58. echo 'OK';
  59. }
  60.  
  61. }
  62. else
  63. {
  64. echo '<div class="notification_error">'.$error.'</div>';
  65. }
  66.  
  67. }
  68. ?>
Any ideas would be great.
Thanks in advance
Richard
Nov 24 '14 #1
3 1609
Luuk
1,047 Recognized Expert Top Contributor
try:
Expand|Select|Wrap|Line Numbers
  1. define("CONTACT_FORM", 'contact@mysite.co.uk, secondemail@hotmail.com');
  2.  
Nov 24 '14 #2
fran7
229 New Member
Hi, Thanks for the reply. I tried that but got the error. email not on server. I am trying to get it to redirect to a second email not on the server. Perhaps I should have specified that.
Thanks again
Richard
Dec 9 '14 #3
Exequiel
288 Contributor
if there are 2 or more recipients you can loop the part where you will send your email. you can put arrays for emails and loop that.
Dec 10 '14 #4

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

Similar topics

1
2060
by: Kelly | last post by:
Can anyone see why this wouldn't work? I get the mail but it is always blank. The key is installed on the server properly (so I am told). Basically the encrypting of the message seems to be the...
0
1220
by: bill joyce | last post by:
I am using a datagrid to populate a spreadhseet. The code works fine (posted below formated to fit in this box, any suggestions/better way let me know). The problem is that the excel instance is...
7
16568
by: Susan Bricker | last post by:
I would like to generate a report (I have the report working already) using MS/ACCESS 2000 and then have the ability to send the report as an email attachment to my colleagues. I have looked...
10
4951
by: OdAwG | last post by:
Hello All, Is it possible to send an email from Access? I found a Microsoft article on how to do this but I keep getting an error "RUNTIME ERROR 438" -- Object doesn't support this property or...
3
332
by: JaffaCakes | last post by:
I want to send an email confirmation after a user completes a form on our Internet page. I am testing this with the System.Web.Mail.SmtpMail class. If I do a SmtpMail.Send then the message takes...
2
2021
by: comp.lang.php | last post by:
I came up with functions that I thought would do the trick: if (!function_exists('smtp_close')) { /** * This function will close a socket resource handle * * Original function found at...
1
1720
by: rahulthathoo | last post by:
Hi, After i finish some amount of computation using a perl script, i need to send out an email to a receipient which can change and is known to the Perl script. Is there a way to call the...
0
1287
by: .spider | last post by:
Hi, I have a code here (taken from http://www.dotnetwatch.com/page294.aspx). Now i didn't think there was anything wrong with this code(no compilation errors..nothing)..and infact when i ran this...
5
3285
by: robtech4 | last post by:
I have this code, curtisy of Twinnyfo but I am looking to add another recipient email address as a "cc". Can you please advise on the addition to the code... Private Sub cmdSubmit_Click() On...
0
7171
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
7545
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...
1
7111
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7539
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...
0
3240
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
3228
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1605
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 ...
1
807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
461
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.