Can't get embedding image to work in my mail

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
hebus
Forum Newbie
Posts: 1
Joined: Wed Sep 08, 2010 6:37 am

Can't get embedding image to work in my mail

Post by hebus »

I can't get embedding image to work in my code. (i want to embed : logo_mail.gif)
a second problem is that i always get 2 x mail .

Can sombody show me the way :)
This already works :

Code: Select all

<?php
 
//mail versturen

require_once 'mailer/swift_required.php';


//Compleet bericht	
$body_compleet=
'
<html>
<style type="text/css">
<!--
.style1 {color: #9191FF}
.style2 {font-size: 16px}
-->
</style>
<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0" bgcolor="#4faff6" >
<span class="style1">
<STYLE>
 .headerTop { background-color:#0099FF; border-top:0px solid #000000; border-bottom:1px solid #FFFFFF; text-align:center; }
 .adminText { font-size:10px; color:#996600; line-height:200%; font-family:verdana; text-decoration:none; }
 .headerBar { background-color:#FFFFFF; border-top:0px solid #333333; border-bottom:10px solid #FFFFFF; }
 .title { font-size:20px; font-weight:bold; color:#CC6600; font-family:arial; line-height:110%; }
 .subTitle { font-size:11px; font-weight:normal; color:#666666; font-style:italic; font-family:arial; }
 .defaultText { font-size:12px; color:#000000; line-height:150%; font-family:trebuchet ms; }
 .footerRow { background-color:#FFFFCC; border-top:10px solid #FFFFFF; }
 .footerText { font-size:10px; color:#996600; line-height:100%; font-family:verdana; }
 a { color:#FF6600; color:#FF6600; color:#FF6600; }
</STYLE>
</span>
<table width="100%" cellpadding="10" cellspacing="0" class="backgroundTable" bgcolor="#4faff6" >
<tr>
<td valign="top" align="center">
<table width="550" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" align="center" style="background-color:#FFCC66;border-top:0px solid #000000;border-bottom:1px solid #FFFFFF;text-align:center;"><span style="font-size:10px;color:#996600;line-height:200%;font-family:verdana;text-decoration:none;">Deze mail is automatich verzonden. Doe geen reply op deze mail.</a></span></td>
</tr>
<tr>
<td style="background-color:#FFFFFF;border-top:0px solid #333333;border-bottom:10px solid #FFFFFF;"><center>
  <a href=""></a>
  <span style="font-size:20px;font-weight:bold;color:#009900;font-family:arial;line-height:110%;"><span class="style2">'.$titel.'</span></span>
</center></td>
<td style="background-color:#FFFFFF;border-top:0px solid #333333;border-bottom:10px solid #FFFFFF;"><a href="http://www.reynaertkringdaknam.be"><img src="logo_mail.gif"  width="24" border="0" align="center"></a></td>
</tr>
</table>
<table width="550" cellpadding="20" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td bgcolor="#FFFFFF" valign="top" style="font-size:12px;color:#000000;line-height:150%;font-family:trebuchet ms;">'.$body.'
</p>
</td>
</tr>
<tr>
<td style="background-color:#99CC00;border-top:10px solid #FFFFFF;" valign="top">
  <p style="font-size:10px;color:#666666;line-height:100%;font-family:verdana;"> REYNAERTKRING DAKNAM v.z.w. 
  <br/>
  Website:www.reynaertkringdaknam.be
  </p>
  </td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
';
		
		
//Create the Transport
$transport = Swift_SmtpTransport::newInstance('******',*****)
->setUsername('********')
->setPassword('******');
$mailer = Swift_Mailer::newInstance($transport);
	  
//Create the message
$message = Swift_Message::newInstance()
		
//Give the message a subject
->setSubject($onderwerp)
		
//Set the From address with an associative array
->setFrom(array('*********@reynaertkringdaknam.be' => 'Website Reynaertkringdaknam'))
		
//Set the To addresses with an associative array
->setTo(array($mail_adres))

//Give it a body
 ->setBody($body_compleet,'text/html', 'iso-8859-1');
	$result = $mailer->send($message);
	if (!$mailer->batchSend($message, $failures))
		{
		echo "Failures:";
		print_r($failures);
		} 

?>
Post Reply