Mail body doesn't show when a file attached
Posted: Fri Nov 14, 2008 9:19 am
Hi I am trying to send an email with swift mailer. It works well but when I add an attachment
the mail succesfully reach to the recipients and I can see the attachment but the mail body doesn't
displayed. Mail source is like this
PHP code is like that
Another problem is, as you see I am trying to attach more than one document, I think I am doing sth wrong because
in that way only the last element of array sending with mail.
the mail succesfully reach to the recipients and I can see the attachment but the mail body doesn't
displayed. Mail source is like this
Code: Select all
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="_=_swift-28890491d90ef4655a1.67157877_=_"
Content-Transfer-Encoding: 7bit
Message-ID: <20081114145335.2052.33931755.swift@localhost>
<p>Ingilizce bey,</p>
<p>mail details</p>
--_=_swift-28890491d90ef4655a1.67157877_=_
Content-Type: application/octet-stream; name=ingiltere-ogrenci-rehberi.doc
Content-Transfer-Encoding: base64
Content-Description: ingiltere-ogrenci-rehberi.doc
Content-Disposition: attachment; filename=ingiltere-ogrenci-rehberi.doc
0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAAEAAAA5AEAAAAA
AAAAEAAA5gEAAAEAAAD+////AAAAAOABAADhAQAA4gEAAOMBAAD/////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
Code: Select all
<?php
require_once "lib/Swift.php";
require_once "lib/Swift/Connection/SMTP.php";
$smtp =& new Swift_Connection_SMTP("mail.example.com", 25);
$smtp->setUsername("site@example.com");
$smtp->setpassword("utf");
$smtp =& new Swift($smtp);
$message =& new Swift_Message($subject, $message, "text/html");
$message->setCharset("utf-8");
if(is_array($header["attach"])) {
foreach($header["attach"] as $key => $value) {
$message->attach(new Swift_Message_Attachment(
new Swift_File("dokuman/".$value["ad"]), $value["ad"]),'application/msword');
}
}
if ($smtp->send($message, $email, "site@example.com")){
//echo "Message sent";
}
?>
in that way only the last element of array sending with mail.