Code: Select all
$html_part = '
Here is an inline image! <img src="'.$mailer->addImage('/path/to/beach.png').'"/>
do you like it?
';Moderator: General Moderators
Code: Select all
$html_part = '
Here is an inline image! <img src="'.$mailer->addImage('/path/to/beach.png').'"/>
do you like it?
';You got it buddy... as long as Swift loads in the attachment as inline data and passes back the correct identifier for it that will work nicelyWeirdan wrote:option two, definitely. perhaps something along the lines of:could be even better, as it allows easy customization of img attributes.Code: Select all
$html_part = ' Here is an inline image! <img src="'.$mailer->addImage('/path/to/beach.png').'"/> do you like it? ';
Code: Select all
<?php
require('class.phpmailer.php');
$mail = new PHPMailer;
$mail->From = 'someone@tld';
$mail->FromName = 'Someone';
$mail->Host = 'smtp.host.tld';
$mail->Mailer = 'smtp';
$mail-Subject = 'Some subject';
$mail->Body = 'The email body';
$mail->AddAddress('recipient@tld', 'Recipient Name');
if (!$mail->Send()) echo 'Not sent!';
$mail->ClearAddresses();
?>Code: Select all
<?php
require('Swift.php');
require('Swift/Swift_SMTP_Connection.php');
$mail = new Swift(new Swift_SMTP_Connection('smtp.host.com'));
if (!$mail->send(
'"Recipient Name" <recipient@tld>',
'"Someone" <someone@tld>',
'Some subject',
'This is the body')) echo 'Not sent!';
?>Code: Select all
<?php
require('class.phpmailer.php');
$mail = new PHPMailer;
$mail->From = 'someone@tld';
$mail->FromName = 'Someone';
$mail->Host = 'smtp.host.tld';
$mail->Mailer = 'smtp';
$mail->IsHTML();
$mail-Subject = 'Some subject';
$mail->Body = '<em>HTML</em> part';
$mail->AltBody = 'Plain part';
$mail->AddAddress('recipient@tld', 'Recipient Name');
if (!$mail->Send()) echo 'Not sent!';
$mail->ClearAddresses();
?>Code: Select all
<?php
require('Swift.php');
require('Swift/Swift_SMTP_Connection.php');
$mail = new Swift(new Swift_SMTP_Connection('smtp.host.com'));
$mail->addPart('Plain part');
$mail->addPart('<em>HTML</em> part', 'text/html');
if (!$mail->send(
'"Recipient Name" <recipient@tld>',
'"Someone" <someone@tld>',
'Some subject')) echo 'Not sent!';
?>Code: Select all
<?php
require('class.phpmailer.php');
$mail = new PHPMailer;
$recipients = array('one@tld', 'two@tld', 'three@tld', 'four@tld');
$mail->From = 'someone@tld';
$mail->FromName = 'Someone';
$mail->Host = 'smtp.host.tld';
$mail->Mailer = 'smtp';
$mail-Subject = 'Some subject';
$mail->Body = 'Body';
foreach ($recipients as $address)
{
$mail->AddAddress($address);
if (!$mail->Send()) echo 'Not sent!';
$mail->ClearAddresses();
}
?>Code: Select all
<?php
require('Swift.php');
require('Swift/Swift_SMTP_Connection.php');
$mail = new Swift(new Swift_SMTP_Connection('smtp.host.com'));
$recipients = array('one@tld', 'two@tld', 'three@tld', 'four@tld');
if (!$mail->send(
$recipients,
'"Someone" <someone@tld>',
'Some subject',
'Body')) echo 'Not sent!';
?>Code: Select all
<?php
require('class.phpmailer.php');
$mail = new PHPMailer;
$file = '../files/myimage.jpg';
$filename = 'My Image.jpg';
$mail->From = 'someone@tld';
$mail->FromName = 'Someone';
$mail->Host = 'smtp.host.tld';
$mail->Mailer = 'smtp';
$mail-Subject = 'Some subject';
$mail->Body = 'Body';
$mail->AddAddress('recipient@tld', 'Recipient Name');
$mail->AddAttachment($file, $filename);
if (!$mail->Send()) echo 'Not sent!';
$mail->ClearAddresses();
$mail->ClearAttachments();
?>Code: Select all
<?php
require('Swift.php');
require('Swift/Swift_SMTP_Connection.php');
$mail = new Swift(new Swift_SMTP_Connection('smtp.host.com'));
$file = '../files/myimage.jpg';
$filename = 'My Image.jpg';
$mail->addPart('Body');
$mail->addAttachment(file_get_contents($file), $filename);
if (!$mail->send(
'"Recipient Name" <recipient@tld>',
'"Someone" <someone@tld>',
'Some subject')) echo 'Not sent!';
?>Code: Select all
<?php
require('class.phpmailer.php');
$mail = new PHPMailer;
$cid = 'abcdefg123456';
$image = '../files/myimage.jpg';
$mail->IsHTML();
$mail->From = 'someone@tld';
$mail->FromName = 'Someone';
$mail->Host = 'smtp.host.tld';
$mail->Mailer = 'smtp';
$mail-Subject = 'Some subject';
$mail->Body = '<strong>So here is where we went!</strong><br />
<img src="cid:'.$cid.'" alt="Somewhere" /><br />
Pretty nice eh?';
$mail->AddEmmbeddedImage($file, $cid);
$mail->AddAddress('recipient@tld', 'Recipient Name');
if (!$mail->Send()) echo 'Not sent!';
$mail->ClearAddresses();
$mail->ClearAttachments();
?>Code: Select all
<?php
require('Swift.php');
require('Swift/Swift_SMTP_Connection.php');
$mail = new Swift(new Swift_SMTP_Connection('smtp.host.com'));
$image = '../files/myimage.jpg';
$mail->addPart('<strong>So here is where we went!</strong><br />
<img src="'.$mail->addImage($image).'" alt="Somewhere" /><br />
Pretty nice eh?', 'text/html');
if (!$mail->send(
'"Recipient Name" <recipient@tld>',
'"Someone" <someone@tld>',
'Some subject')) echo 'Not sent!';
?>Code: Select all
<?php
/** Forget it - TLS is not supported **/
?>Code: Select all
<?php
require('Swift.php');
require('Swift/Swift_SMTP_Connection.php');
//I had this automated but it was flaky - I'll try to remove the need to do this again
$mail = new Swift(new Swift_SMTP_Connection('smtp.gmail.com', false, SWIFT_TLS));
$mail->authenticate('user@gmail.com', 'pass');
if (!$mail->send(
'"Recipient Name" <recipient@tld>',
'"Someone" <someone@tld>',
'Some subject',
'The body')) echo 'Not sent!';
?>By the way, the only sort of benchmarking I've ever done is speed tests.... I'll do those. But how would I most accurately measure memory/cpu usage? I use linux which I'm guessing helpsRoja wrote:Yes. Thats just what I was looking for.d11wtq wrote:Haven't had time to benchmark yet... was this what you were looking for though?
Looking forward to the benchmark results.
Code: Select all
--
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
Have a look at durhaml!!
__________ NOD32 1.1454 (20060321) Information __________
This message was checked by NOD32 antivirus system.
http://www.eset.com
--
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: 7bit
Have a look at durham <strong>NOW</strong>!!
----
--swift-8EF4BA73109BE3CC234E467848266FFC
Content-Type: application/vnd.ms-word; name="how_can_we_help_you.web_page9.doc";
Content-Transfer-Encoding: base64
Content-Description: how_can_we_help_you.web_page9.doc
Content-Disposition: attachment; filename="how_can_we_help_you.web_page9.doc"
0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAABAAAAKQAAAAAAAAAA
EAAAKwAAAAEAAAD+////AAAAACgAAAD/////////////////////////////////////////
EAAAKwAAAAEAAAD+////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////s
[*snip*]Code: Select all
echo chunk_split(base64_encode(file_get_contents($file)));Code: Select all
0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAABAAAAKQAAAAAAAAAA EAAAKwAAAAEAAAD+////AAAAACgAAAD///////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////s pcEATSAJBAAA8BK/AAAAAAAAEAAAAAAABAAACAkAAA4AYmpiauI94j0AAAAAAAAAAAAAAAAAAAAA AAAJBBYALhYAAIBXAACAVwAACAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//w8AAAAA AAAAAAD//w8AAAAAAAAAAAD//w8AAAAAAAAAAAAAAAAAAAAAAGwAAAAAACABAAAAAAAAIAEAACAB AAAAAAAAIAEAAAAAAAAgAQAAAAAAACABAAAAAAAAIAEAABQAAAAAAAAAAAAAADQBAAAAAAAAdAMA AAAAAAB0AwAAAAAAAHQDAAAAAAAAdAMAAAwAAACAAwAADAAAADQBAAAAAAAAABMAADIBAACYAwAA AAAAAJgDAAAAAAAAmAMAAAAAAACYAwAAAAAAAJgDAAA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