Jump to content

Archived

This topic is now archived and is closed to further replies.

masgas

error sending mails from array!

Recommended Posts

Hi again!

I'm here trying to send some mails to a list from MySQL db, with this class from Richard Hayes and it worked fine for one adress, but when I (of course) tried to do it for more people it gave this error! (I guess it is in the $mai->send(array... somewhere!! But I am not sure! Any ideas!?

I get this error message:

Warning: mail() [function.mail]: SMTP server response: 501 <$email> Invalid mail address, must have a domain part in C:\xampp\htdocs\soa\htmlMimeMail5\htmlMimeMail5\htmlMimeMail5.php on line 743

thanks you...

if (Send == $_REQUEST[Send]) {

$con=mysql_connect('','','') or die ('no conn serv');
    mysql_select_db('mailertest') or die ('no conn db');     
$sql = "SELECT * FROM mails WHERE Nivel = '$Nivel'";
$display = mysql_query ($sql) or die ('error');
while ($row = mysql_fetch_array($display)) {
$Name = $row["Name"];
$email = $row["email"];
$Surn = $row["Surn"];
   
   
   


    require_once('../htmlMimeMail5.php');
   
    $mail = new htmlMimeMail5();

    /**
    * Set the from address
    */
    $mail->setFrom('Masgas <MyMail@ono.com>');
   
    /**
    * Set the subject
    */
    $mail->setSubject('Test email');
   
    /**
    * Set high priority
    */
    $mail->setPriority('high');

    /**
    * Set the text of the Email
    */
    $mail->setText('Sample text');
   
    /**
    * Set the HTML of the email
    */
    $mail->setHTML('<b>Sample HTML</b> <img src="background.gif">');
   
    /**
    * Add an embedded image
    */
    $mail->addEmbeddedImage(new fileEmbeddedImage('background.gif'));
   
    /**
    * Add an attachment
    */
    $mail->addAttachment(new fileAttachment('example.zip'));

    /**
    * Send the email
    */
   
  $mail->send (array('$email'));
}
}
else { echo "something is wrong";
echo $email;}
?>

Share this post


Link to post
Share on other sites
Well, since you're sending the emails inside the while, you will only send one email each time and not to the whole list. So you should do this:

$mail->send ($email);

instead of this:

$mail->send (array('$email'));

Share this post


Link to post
Share on other sites
great!

you were right about removing the '' from '$email'

but with   $mail->send(array($email)); worked wonders!!!

thanks :)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.