Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

I do not receive emails sent by PHPMailer

0 views
Skip to first unread message

Jivanmukta

unread,
Dec 26, 2009, 9:32:45 AM12/26/09
to
Hello,
I am learning PHP5. I wrote the function sending email. I used
PHPMailer:

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.

Jivanmukta

unread,
Dec 26, 2009, 10:17:33 AM12/26/09
to
I would like to say again that I only know that the email is not
received. I don't know if it was sent because I don't know how to
check it. As you see, I use external SMTP server but the parameters to
the server are valid, I verified.

Peter H. Coffin

unread,
Dec 26, 2009, 5:26:44 PM12/26/09
to

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

Jivanmukta

unread,
Dec 27, 2009, 6:15:27 AM12/27/09
to
> 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.

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?

Jerry Stuckle

unread,
Dec 27, 2009, 7:54:24 AM12/27/09
to

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
==================

Message has been deleted

"Álvaro G. Vicario"

unread,
Dec 28, 2009, 6:01:23 AM12/28/09
to
El 26/12/2009 15:32, Jivanmukta escribi�:

> 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)) {

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
--

0 new messages