function sendEmail($to, $recipients, $subject, $bodyText, $bodyHTML,
$fullAnnouncementNo, $withAttachments, $logEntry) {
global $db, $websiteRoot;
try {
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = ...;
$mail->SMTPAuth = true;
$mail->Username = ...;
$mail->Password = ...;
$mail->From = ...;
$mail->AddReplyTo(...);
if (!empty($to)) {
$mail->AddAddress($to);
}
if (!empty($recipients)) {
foreach (explode(',', $recipients) as $bcc) {
$mail->AddBCC($bcc);
}
}
$mail->IsHTML(!empty($bodyHTML));
$mail->Subject = $subject;
if (!empty($fullNo)) {
getYearMonthNo($fullNo, $year, $month, $no);
}
$mail->MsgHTML($bodyHTML);
$mail->AltBody = $bodyText;
if ($withAttachments && !empty($fullNo)) {
$result = $db->query('SELECT file_name, picture FROM pictures
' .
"WHERE a_year = $year AND a_month =
$month AND a_no = $no");
@mkdir($websiteRoot . '/tmp/' . $fullNo);
while ($row = $result->fetch_row()) {
createPicture($websiteRoot . '/tmp', $fullNo, $row[0], $row
[1]);
$mail->AddAttachment("$websiteRoot/tmp/$fullNo/$row[0]");
}
$result->close();
removeDirectory($websiteRoot . '/tmp/' . $fullNo);
}
if (!$mail->Send()) {
return false;
}
} catch (phpmailerException $e) {
return false;
} catch (Exception $e) {
return false;
}
if (!empty($fullNo)) {
writeToLog(null, null, $currentAdmin, $year, $month, $no,
$logEntry);
} else {
writeToLog(null, null, $currentAdmin, null, null, null,
$logEntry);
}
return true;
}
The problem is that I do not receive any emails sent by the function.
I don't know why.
I learned from someone that there is a version of PHPMailer that
allows the programmer to check the reason of error but I don't know
where to download it from. I would like to use PHPMailer because I use
attachments and I had problems with PEAR mail.
Please help. Thanks in advance.
Sadly, the easiest place to answer this question is starting with the
SMTP logs. That will tell you whether the mail actually got submitted
and what happened to it after that.
--
2. My ventilation ducts will be too small to crawl through.
--Peter Anspach's list of things to do as an Evil Overlord
Can I check in PHP if the mail was sent?
What are possible solutions for sending email with attachment in PHP5?
I tried PHPMailer and PEAR. Are there any other solutions?
All you can tell in PHP is if the mail was passed off to the MTA. You
can't determine if it was accepted by the MTA, or, if accepted, was
passed on.
As Peter said - you need the SMTP logs to see what's happening.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================
Regular PHPMailer downloaded from http://phpmailer.sourceforge.net/ has
an ErrorInfo property:
http://phpmailer.worxware.com/index.php?pg=examplebsmtp
--
-- http://alvaro.es - �lvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programaci�n web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--