Interactive
Interactive

Reputation: 1550

PHPMailer add array values to mail

I have this PHPMailer that sends out an email to me if a script has run.

I want to add some array values to the mailcontent but it seems to fail.
When I did my mailing through the mail() function and that worked.

Here is what I have:

$mail = new PHPMailer();
$mail->IsSMTP();                                                    
$mail->Host = 'www.domain.com';                 
$mail->Port = 465;                                              
$mail->SMTPAuth = true;                                         
$mail->Username = "usernamen.nl";    
$mail->Password = "password";                           
$mail->SMTPSecure = 'ssl';                                      

$mail->From = '[email protected]';
$mail->FromName = 'Import Users';
$mail->AddAddress('[email protected]', 'CronJob results'); 

$mail->IsHTML(true);                                                

$mail->Subject = 'CronJob results';
$mail->Body    = 'Updated users'.implode($update, "<br />").'

                Added users'.implode($add, "<br />").'

                Deleted users'.implode($delete, "<br />").'
                                                ';

if(!$mail->Send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
    exit;
}

$update, $add and $delete are the array that are filled with their corresponding data.

M.

Upvotes: 0

Views: 1079

Answers (1)

Syed mohamed aladeen
Syed mohamed aladeen

Reputation: 6755

you are making a small mistake in implode. you should use implode like this

implode( "<br />",$add);

Upvotes: 2

Related Questions