Swiftmailer-4.0.5
PHP v5.2.12
Problem:
When i tried to embed an image into html type mail, only outlook with
a low spam filter sends the mail to junk folder.Target mail has a text part,
an html part, one pdf file as an attachment and 3 embeded images (like logo).
Output of Outlook
Received: from ....
Date: Fri, 8 Jan 2010 09:14:31 +0200
From: Ocompany [email protected]
Subject: Please check the ...
To: [email protected]
Message-ID: [email protected]
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="Boundary_(ID_CRI1zed9hsGT8qmRuQcTgg)"
X-AntiAbuse: This header was added to track abuse,
please include it with any abuse report
X-AntiAbuse: Primary Hostname - bursa.trial.com
X-AntiAbuse: Original Domain - xxx.com
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - example.com
X-NAI-Spam-Level: ***
X-NAI-Spam-Score: 3
X-NAI-Spam-Report: 4 Rules triggered
- 1 -- BODY_LONG_LINE_PARA_IMG_ATTACH_NOHTTP -- Spam trait in body
- 1 -- CT_IMG_FLAT -- Spam trait in body
- 1 -- CT_MP_MIXED_SPACE_BNDRY_IMG -- Spam trait in body
- 0 -- RV3443 -- BODY: Version number
Return-Path: [email protected]
Output of Webmail
Return-path: [email protected]
Envelope-to: [email protected]
Delivery-date: Fri, 08 Jan 2010 08:57:09 +0200
Received: from ...
Message-ID: [email protected]
Date: Fri, 08 Jan 2010 08:57:09 +0200
Subject: Please check ...
From: Ocompany [email protected]
To: [email protected]
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="=swift_v4_12629338294b46d745129d0="
--=swift_v4_12629338294b46d745129d0=
Content-Type: multipart/related;
boundary="=swift_v4_12629338294b46d7457e02d="
--=swift_v4_12629338294b46d7457e02d=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
No visibility in plain text, in html version you will see ....
--=swift_v4_12629338294b46d7457e02d=
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
<style type=3D"text/css"> .div_info { width:600px; margin:0px;=
padding:0px; padding-left:10px; line-height:140%; font-family:Verdana, =
Geneva, sans-serif; font-size:12px; font-style:normal; color:#150517 }
dddddddddddddddddddddddddddddddddd<=
p>................................................................=
........................................................................=
.............................................
--=swift_v4_12629338294b46d7457e02d=
Content-Type: image/gif; name=newgen.gif
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename=newgen.gif
Content-ID: [email protected]
R0lGODlhUAAPAIQAAAAAAL6+vr+/v8DAwMHBwcLCwsTExMjIyMvLy87Ozt7e3u7u7vHx8fX19fj4
+Pn5+fr6+vv7+/z8/P39/f///wAAAAAAAAAAAAAA............Mjv7/vUtAgocSNBECAA7
--=swift_v4_12629338294b46d7457e02d=--
--=swift_v4_12629338294b46d745129d0=
Content-Type: application/pdf; name=1262933801_2009_09_23_cr_senkromec.pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename=1262933801_2009_09_23_cr_senkromec.pdf
JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PC9MZW5ndGggNiAwIFIvRmlsdGVyIC9GbGF0ZURlY29k
ZT4+CnN0cmVhbQp4nN2dTaw1R53ej31txryK0J2JQRPC4mrMiHOdedtdH13VZY0m4TUfYcJ4PPBO
ZsFEYGxjPP7E2Mxkl0SJAsqsZoUg4k............................lRU9GCg==
--=swift_v4_12629338294b46d745129d0=--
Here is the code i used
@@@
require_once '../Swift-4.0.5/lib/swift_required.php';
$transport = Swift_SmtpTransport::newInstance('mail.example.com', 587)
->setUsername('info+example.com')
->setPassword('xxxxx');
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance();
$message->setSubject($subject);
$message->setFrom(array($sender => ucfirst(strtolower($company))));
$message->setTo($m); //$m is 1 degree array of mail adresses
$headers = $message->getHeaders();
/$cidcom = $message->embed(Swift_Image::fromPath($URL_IMG_COM));/
// $URL_IMG_COM="../upload_img/".$_SESSION['companyID']."/".$logo; image path..
$message->setBody('No visibility in plain text, in html version '.
'This mail was generated for a company who is '.$sectorcom.'.'.
'Five more lines take place in here.... '.
'and close the plain text', 'text/plain');
// not whole html code, only one image embed sample is here..
$message->addPart(''.
''.
'<style type="text/css">'.
' .div_info { width:600px; margin:0px; padding:0px;'.
' padding-left:10px; line-height:140%; font-family:Verdana, Geneva, sans-serif;'.
' font-size:12px; font-style:normal; color:#150517 }'.
'</style>'.
'' .
'
dddddddddddddddddddddddddddddddddd
'.
''.
'This mail was generated for '.ucfirst(strtolower($company)).' who is '.$sectorcom.'.'.
'.................................................... '.
'.................................................
'.
'
....................................................'.
'....................................................'.
'... '.ucfirst(strtolower($company)).', ..............
'.
'
....................................................
'.
'
.................................................... '.
'......... '.ucfirst(strtolower($company)).'.......... '.
'......... '.ucfirst(strtolower($company)).' .........
'.
'
....................................................
'.
'
'.ucfirst(strtolower($company)).'...:
'.
'
'.$db_description.'
'.
'...................:
'.
'..... '.ucwords($db_projectname).'
'.
'..... '.$db_time.' days
'.
'..... '.$target.'
'.
'', 'text/html');
$message->attach(Swift_Attachment::fromPath($_SESSION['rfq']['path']));
printf("%s
\n", $headers->toString());
if (!$mailer->batchSend($message, $failures))
{
echo "Failures:";
print_r($failures);
}
@@@
Conclusion
I will appreciate if you can show me the correct way to prepare the Target Mail.
Thanks.
Ozcan
Original creation date: 2010-01-08T08:17:25Z
Original reporter: Maciej Lisiewski
Original ticket: http://swiftmailer.lighthouseapp.com/projects/21527/tickets/121