Mailing from MySQL variable containing users email address fails:
$sendto = $row['emailb'];
$from = "<support@mydomain.com>";
$subject = "Monthly News from MyDomain";
$mss = "Newsletter body";
$mss .= "Thank you \n\n";
mail($sendto, $subject, $mss,"FROM: $from");
$row['emailb'] gets a valid email from MySQL as I have echoed it to the screen to check.
This works just fine:
$sendto = "support@mydomain.com";
$from = "<support@mydomain.com>";
$subject = "Monthly News from MyDomain";
$mss = "Newsletter body";
$mss .= "Thank you \n\n";
mail($sendto, $subject, $mss,"FROM: $from");
This works fine also
$sendto = "support@mydomain.com,".$row['emailb'];
$from = "<support@mydomain.com>";
$subject = "Monthly News from MyDomain";
$mss = "Newsletter body";
$mss .= "Thank you \n\n";
mail($sendto, $subject, $mss,"FROM: $from");
I just can't get the email to send if I use a variable from MySQL
Thanks!
PHP Mail from MySQL
Moderator: General Moderators
-
brianharrell
- Forum Newbie
- Posts: 5
- Joined: Tue Mar 11, 2003 10:36 am
- Location: MN USA
are you sure your useing a loop to send emails? or are you just trying to send 1 email? if you have more then 1 email then you will have to loop to get each email and send it off. e.g.
that would do it ^^^^
Code: Select all
<?php
$query = mysql_query("select email from table");
while($row = mysql_fetch_array($query))
{
mail($row[email], $subject, $message, $extra_headers);
}
?>that would do it ^^^^
-
Cruzado_Mainfrm
- Forum Contributor
- Posts: 346
- Joined: Sun Jun 15, 2003 11:22 pm
- Location: Miami, FL