bcart Posted January 19, 2010 Share Posted January 19, 2010 Hi there I'm trying to bulk email people at work with the script below. It works fine when I actually type 1 email address against the $to variable but when I assign $to against a loop through all of the ones I want to then it produces the following error "Warning: mail() [function.mail]: SMTP server response: 550 Relaying denied in C:\xampp\htdocs\intranet\staff_satisfaction\mailer.php on line 51" The code I'm using is this <?php if (isset($_POST['submitted'])) { $q = "SELECT * FROM ss_staff"; $r = mysqli_query($dbc, $q); $row = mysqli_fetch_array($r); do { $recipients .= '\'' . $row['email'] . '@totalpeople.co.uk\', '; } while ($row = mysqli_fetch_array($r));//end of while loop $to = substr($recipients, 0, -2); $body = "body of email"; $email = '[email protected]'; $subject = 'Subject of email'; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; // Send the email: $sendMail = mail($to, $subject, $body, $headers); //mail($to, $subject, $body, $headers); if ($sendMail) { echo '<h2>Congratulations! You have successfully mailed everyone.</h2>'; exit(); } else { // Public message: echo "<h1>System Error</h1> <p class=\"error\">This didn't work. $to</p>"; // Debugging message: echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $q . '</p><br /><br /><br /><br />'; exit(); // Quit the script. } } else { echo '<form action="mailer.php" method="post"> <input type="submit" name="submit" value="Submit" /> <input type="hidden" name="submitted" value="TRUE" /> </form>'; }//end of main if ?> Can anyone help? Thanks! Link to comment https://forums.phpfreaks.com/topic/189033-mail-error/ Share on other sites More sharing options...
o3d Posted January 19, 2010 Share Posted January 19, 2010 That message is a response from the smtp mail server trying to send your email. Most sites found on google suggest that it might be an authentication error (smtp auth). If this error only happens with a certain email address, find that address (or addresses) and email the mail administrator as to why the smtp server is not allowing the mail to be relayed. Link to comment https://forums.phpfreaks.com/topic/189033-mail-error/#findComment-998228 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.