Jump to content


Photo

error sending mails from array!


  • Please log in to reply
2 replies to this topic

#1 masgas

masgas
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 23 September 2006 - 04:31 PM

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;}
?>

#2 yonta

yonta
  • Members
  • PipPipPip
  • Advanced Member
  • 70 posts

Posted 23 September 2006 - 05:06 PM

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'));
do it, do it right, do it right now

#3 masgas

masgas
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 23 September 2006 - 05:32 PM

great!

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

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

thanks :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users