473,396 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Add second recipient to email

229 100+
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

✓ answered by Exequiel

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.

3 1608
Luuk
1,047 Expert 1GB
try:
Expand|Select|Wrap|Line Numbers
  1. define("CONTACT_FORM", 'contact@mysite.co.uk, secondemail@hotmail.com');
  2.  
Nov 24 '14 #2
fran7
229 100+
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 256MB
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
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
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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,...
0
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
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
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...

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.