![]() |
PHP Mail() Query
Trying to use mail() to send to 2 recipients, as mail('[email protected],[email protected]', 'etc', 'etc') but it only ever sends to the first. Wot am I doing wrong please?
|
Tried that and no success. The PHP guide actually calls for a ,
|
<?php
require("class.phpmailer.php"); $mail= new PHPMailer(); $mail->AddAddress("[email protected]"); $mail->AddAddress("[email protected]"); $mail->Body = "shredded wheat sucks"; $mail->send(); ?> |
Thanks for reply, F8, but I have a form mail task and cannot see how to fit that in. This is where I am at:
<?php if($_POST[submit]) { $message = "Your inside leg:\r\n$_POST[field1]\r\n Your etc etc; Your etc etc; 'mail([email protected],[email protected], 'TITLE', $message,'From: email addy'); 'echo ' Thank you - Message sent.'; '} 'else '{ '?> <form action="" method="post"><br> <br> Your inside leg:<br> <input type="text" size="40" maxlength="40" textarea name="field1"><br><br> Your etc etc <input type="submit" name="submit" value="Submit Form"> </form> Probably a few ;'s and <'s missing in the copying but it works to a single address and it is the multiple email addresses function I seek - or a major rewrite to your code :-((( |
Sorry I am no "expert" on these things!
Did you look at: http://uk3.php.net/function.mail ?? It may help - anyhow good luck! |
Yep! It also says "[email protected], [email protected]" but that only seems to send to the first with me.
Its going to be one of those :ugh: answers - I know it...... |
why not do the following:
on the form to be posted: <input type="submit" name="submit" value="myvalue"> and on the page it post's to.... $value = $_POST['myvalue']; or $value = $_GET['myvalue']; (cant remember which one you need) and then the code I mentioned.... anyway something like this... I really am an amateur at coding but I did play around quite a bit a few years back! |
Hi BOAC,
try your code with a space between the comma and the second email address. also put a ' symbol directly before the first email address and another ' symbol directly after the second email address. finally try saving the email addresses to a variable and then dropping that into the mail function as follows. $to = '[email protected]' . ', '; // note the comma $to .= '[email protected]'; mail($to, $subject, $message, $headers); // note no ' sybmols before or after the $to variable failing that how about just looping your code so that you send the email twice - once to each address? MrS |
Does it matter whether 'single' or "double" quotes are used? I think you should be using single quotes, as per that PHP website. Your first code snippet had no quotes, your second had double quotes...
All the '.' operators are doing, in that PHP code, is concatenating the strings - it shouldn't be a requirement. So it looks to me like you need the addresses surrounded by single quotes, with a comma and a space between them. :8 'mail('[email protected], [email protected]', 'TITLE', $message,'From: email addy'); |
Thanks for those ideas - I THINK I've tried them all but will re-do today.
As I thought, had tried all those and it would NOT play ball with multiple addys. Hats off to MrSurrey for kicking the brain cell into life. Simply put a duplicate mail('[email protected]', 'TITLE', $message,'From: email addy'); in the script and BINGO. Thanks to all for ideas. |
Originally Posted by bnt
(Post 3849462)
Does it matter whether 'single' or "double" quotes are used? I think you should be using single quotes, as per that PHP website.
to parameter needs spaces http://uk.php.net/manual/en/function.mail.php If that doesn't work then yes, your workaround will - call mail() twice. Fine except you don't really want to call it too much as automating that function can be construed as spam and you don't want that risk. |
| All times are GMT. The time now is 02:37. |
Copyright © 2026 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.