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 has been submitted.
-
if ( isset ($_POST['submit'])) {
-
-
$problem = FALSE;
-
-
//Check for each value.
-
-
if (empty ($_POST['email2'])) {
-
$problem = TRUE;
-
print '<p>Please enter your email address!</p>';
-
}
-
}
-
-
-
-
-
-
//Display the form.
-
print '<form action="handle_requests.php" method="post"><p>';
-
-
print 'Email Address: <input type="text" name="email2" size="20" ' . $_POST['email2'] . '" /> <br />';
-
-
print '<input type="submit" name="submit" value="Submit Email Address" /></p>
-
</form>';
-
-
// Complete the HTML formatting stuff.
-
print '</div>';
-
-
?>
-
- Code from handle_requests page:
-
-
<html>
-
<head>
-
<title>Request for E-mail Updates Successful!</title>
-
</head>
-
-
<body>
-
-
<?php // Script to handle e-mail requests for updates.
-
-
//Address error handing.
-
ini_set ('display_errors', 1);
-
error_reporting (E_ALL & ~E_NOTICE);
-
-
// In case register_globals is disabled.
-
$email2 = $_POST['email2'];
-
-
-
-
print '<p>Your request for e-mail updates has been successful! You will be receiving a e-mail confirmation shortly.</p>';
-
-
$body = "Thank you for requesting updates. Periodically, we will be sending you information about new material on our website, new publications, and upcoming events. You have registered with the following address: {$_POST['email2']}.";
-
mail ($_POST['email2, address@email.com'], 'Email Confirmation', $body, 'From: address@email.com');
-
-
?>
-
</body>
-
</html>
5 3593 Markus 6,050
Recognized Expert Expert
Hey there, wktarin, and welcome to the forums! Glad to have you here.
Please notice that I have formatted the code you posted in your previous post. To do this just highlight the code and then hit the '#' at the top of this editor. Doing this keeps you inside the laws of the Posting Guidelines. Give them a read.
Moderator.
Markus 6,050
Recognized Expert Expert
I don't quite get what you're trying to do here - mail ($_POST['email2, address@email.com'],
but try changing it to - mail ("{$_POST['email2']}, address@email.com",
Mail().
nathj 938
Recognized Expert Contributor
If you are trying to send the same email to two different addresses you need either send it to yourself and then the 2 real targets in the BCC or process the email addresses in a loop sending the email twice, in each case to only one email address.
I normally build up an array of email addresses and then loop through the array, for each element in the array call the mail() function to send the email to one recipient only. this methodology protects peoples email addresses and respects their privacy.
Cheers
nathj
PS I have an emailObject() class that I use on most of my projects, if you want I can send you a copy of this code and some usage instructions. I think we can do that within Bytes.
@Markus: Sorry about the code gaffe. Must have missed that when I scanned the guidelines. Thanks for your response. I knew my problem had to be something ridiculously simple... But it's fixed and working now!
@nathj: The form will be sent only to the company email address and the subscriber, so the blind carbon isn't a necessity. But thank you for the reminder.
Markus 6,050
Recognized Expert Expert
@Markus: Sorry about the code gaffe. Must have missed that when I scanned the guidelines. Thanks for your response. I knew my problem had to be something ridiculously simple... But it's fixed and working now!
@nathj: The form will be sent only to the company email address and the subscriber, so the blind carbon isn't a necessity. But thank you for the reminder.
Glad you got it working.
Good day.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Fabio Papa |
last post by:
I am trying to write a windows service that sends emails to clients at
specific times based on information in a sql db. Since this is done for
multiple cities, I start a thread for each city and continue the processing
from each thread. My service starts fine (gives me no errors, etc), but it
doesn't seem to start the new threads. I am new to windows services, so I
don't know if I'm doing something wrong. Should I maybe be doing this...
|
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!
|
by: Mr. x |
last post by:
Hello,
I am sending emails with Hebrew contents.
When receiving emails - I cannot see the Hebrew characters (it is not
outlook express configuration, because when receiving emails from friends -
I see hebrew, it is just sending by myself using *.aspx scripts).
In web.config I have the following :
<configuration>
<system.web>
|
by: Steve Thurston |
last post by:
Hi,
I'm attempting to send emails for the first time using ASP.NET, so I'm
hoping there's just a beginner's error going on here for me. But my
emails aren't reaching their destination, and I don't know why.
My "development" machine is just my home machine. I'm connected to
the Internet via an AOL dialup connection.
I am running on XP Pro and my IIS server is (apparently) configured
|
by: VB Programmer |
last post by:
I have an ASPX page where I send out emails through my mail server
mail.MyDomain.com. When I send emails to MyName@MyDomain.com it sends
PERFECTLY. When I try sending an email to any other address
(non-MyDomain.com address) I get the following error:
The server rejected one or more recipient addresses. The server response
was: 550 You must check your mail from this IP or SMTP Auth before sending
to BSmith@Juno.com
Here's the FULL...
| |
by: splicemix |
last post by:
Hi all,
I have recently set up a Drupal website. I am a beginner. My shared
host server does not allow nobody@localhost to send emails, and
prevents access to php.ini, so I spent some time getting a SMTP script
running. While the Drupal feedback module and the new account creation
works fine in terms of sending of mails, I am having some problems with
the sending of password reminder emails.
warning: Cannot modify header information -...
|
by: Philippe Lang |
last post by:
Hello,
I need to send emails from Postgresql triggers.
I was able to do it with a 'plperlu' function, that calls the 'system'
perl function, that itself calls the 'mail' shell function.
Is is safe to do things like this? Is there a possible concurrent access
that could arise?
|
by: bcanter |
last post by:
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...
|
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"
|
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,...
|
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...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |