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

problem sending email with PHPMailer

13 views
Skip to first unread message

Jivanmukta

unread,
Nov 7, 2009, 2:35:38 AM11/7/09
to
Hello,
I wrote a program using PHPMailer. The problem is that email is not
sent.
In include folder I put two packages: class.phpmailer.php and
class.smtp.php.

require_once '../include/class.phpmailer.php';
...
function sendEmailFromOferty($fullAnnouncementNo, $announcement,
$recipients) {
global $db, $websiteRoot;
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = 'smtp.poczta.onet.pl';
$mail->SMTPAuth = true;
$mail->Username = 'jivanmukta';
$mail->Password = ...;
$mail->From = 'jivan...@poczta.onet.pl';
$mail->AddReplyTo('jivan...@poczta.onet.pl');
foreach (explode(',', $recipients) as $bcc) {
$mail->AddBCC($bcc);
}
$mail->IsHTML(true);
$mail->Subject = ...;
getAnnouncementYearMonthNo($fullAnnouncementNo, $year, $month, $no);
$mail->Body = emailMessage(false, $year, $month, $no);
$result = $db->query('SELECT file_name, picture FROM pictures
' .
"WHERE announcement_year = $year AND announcement_month =
$month AND announcement_no = $no");
@mkdir($websiteRoot . '/tmp/' . $fullAnnouncementNo);
while ($row = $result->fetch_row()) {
createPicture($websiteRoot . '/tmp',
$fullAnnouncementNo, $row[0], $row[1]);
$mail->AddAttachment("$websiteRoot/tmp/
$fullAnnouncementNo/$row[0]");
}
$result->close();
if (!$mail->Send()) {
return false;
}
removeDirectory($websiteRoot . '/tmp/' . $fullAnnouncementNo);
return true;
}

The problem is that although $mail->Send() returns not false, email is
not sent. I mean I don't receive any email from my account.
$recipients variable contains valid addresses separated by comma.
Please help.
I don't know what is wrong. My email account data are OK and the
account works
fine. Similar PEAR Mail usage works correctly, but I want to use
PHPMailer.
Thanks in advance.

The Natural Philosopher

unread,
Nov 7, 2009, 3:58:11 AM11/7/09
to
Jivanmukta wrote:
> Hello,
> I wrote a program using PHPMailer. The problem is that email is not
> sent.
> In include folder I put two packages: class.phpmailer.php and
> class.smtp.php.
>
...

> The problem is that although $mail->Send() returns not false, email is
> not sent. I mean I don't receive any email from my account.

Almost certainly the mail is being rejected as invalid by the system you
are sending it from.

Try the -f switch to mail..to set a valid envelope address, as covered
here a few days ago, and elsewhere.

Jivanmukta

unread,
Nov 7, 2009, 10:12:48 AM11/7/09
to
Finally I received an email but after a long time.
But there's a problem with international (Polish) characters - instead
of Polish characters I receive strange symbols, f.e.:

Rodzaj nieruchomo¶ci: lokal
Forma w³asno¶ci: hipoteczna

Please help.

Jivanmukta

unread,
Nov 7, 2009, 10:16:51 AM11/7/09
to

BTW, I use ISO-8859-2 encoding in emailMessage function:


$mail->Body = emailMessage(false, $year, $month, $no);

function emailMessage($cancel, $announcementYear, $announcementMonth,
$announcementNo, $useHTML = true) {
if ($useHTML) {
return
"<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://
www.w3.org/TR/html4/strict.dtd'>\n" .
"<html lang='pl'>\n" .
"<head>\n" .
'<title>' . ($cancel ? 'Anulowanie ogłoszenia' :
'Ogłoszenie') . "</title>\n" .
"<meta http-equiv='Content-Type' content='text/html;
charset=ISO-8859-2'>\n" .
"<meta http-equiv='Content-Language' content='pl-PL'>\n" .
"</head>\n" .
emailMessageBodyHTML($announcementYear,
$announcementMonth, $announcementNo, ($cancel ? 'ANULOWAĆ' :
'zamieścić')) .
'</html>';
} else {
return emailMessageBodyText($announcementYear,
$announcementMonth, $announcementNo, ($cancel ? 'ANULOWAĆ' :
'zamieścić'));
}
}

Jerry Stuckle

unread,
Nov 7, 2009, 1:22:34 PM11/7/09
to

Did you set the charset for the email itself (NOT the HTML charset).

Also, what if your user can't accept html messages? You should also be
sending the same message in plain text.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================

Jivanmukta

unread,
Nov 8, 2009, 10:44:15 AM11/8/09
to
> Did you set the charset for the email itself (NOT the HTML charset).
How? Should I set CharSet property of PHPMailer?

> Also, what if your user can't accept html messages?  You should also be
> sending the same message in plain text.

OK, I set AltBody now.

Jerry Stuckle

unread,
Nov 8, 2009, 12:10:57 PM11/8/09
to
Jivanmukta wrote:
>> Did you set the charset for the email itself (NOT the HTML charset).
> How? Should I set CharSet property of PHPMailer?
>

I would think that's what it's there for...

>> Also, what if your user can't accept html messages? You should also be
>> sending the same message in plain text.
> OK, I set AltBody now.

0 new messages