Please excuse my php but, Im using Swiftmailer to send emails from a clients website. They've requested to add an image or two as a signature etc and so looking at the swiftmailer spec here
http://swiftmailer.org/docs/messages.html
They suggest either adding an inline image like this
$message->embed(Swift_Image::fromPath('http://site.tld/image here'))
or like this(in 2 steps)
$cid = $message->embed(Swift_Image::fromPath('image here'));
then in the emails body section add
<img src="' . $cid . '" alt="Image" />'
Both steps ive tried but to no avail. When i hit the send email button, i get this error which i dont quite know what to make of it.
Call to a member function embed() on a non-object in /home/content/78/5152878/html/4testing/erase/ask-doc-proc2.php on line 89
The only thing i added to my already working code and email was the image code directly from the example in the docs pages. This error obviously prevents the email from being sent. if i remove it then it sends emails fine. Since i need to add an image to this,
Any help is greatly appreciated. Thank you
edit: this is the portion where the email is built and sent $cid= $message->embed(Swift_EmbeddedFile::fromPath('http://myforecyte.com/dev/pic.jpg'));
->setTo( $docEmail)
->setBody("Hello" . "\r\n\r\n" .
$fullName . " has visited MyForeCYTE.com. Upon their visit they have requested to learn more about the test. \r\n\r\n" .
"Please visit www.ClarityWomensHealth.com to find out more about The ForeCYTE Breast Health Test, or call our customer support line at 1 (877) 722-6339. \r\n\r\n" .
"We look forward to hearing from you. \r\n\r\n" .
"Thank You," , 'text/plain')
->addPart("Hello" . ",</b><br/><br/>" .
"<b>" . $fullName . "</b> has visited www.MyForeCYTE.com. Upon their visit they have requested to learn more about the test. <br/>" .
"Please visit www.ClarityWomensHealth.com to find out more about The ForeCYTE Breast Health Test, or call our customer support line at 1 (877) 722-6339.<br/> " .
"We look forward to hearing from you. <br/><br/><br/>" . "<img src='" . $cid. "' alt='pic'/>" .
"Thank you " , 'text/html')
;
image here
, it's a bit hard to tell if it's properly formatted. – Leucomaineline 89
ofask-doc-proc2.php
file? – Leucomainehttp://
or if you're onwww
-http://www.
beforemyforecyte.com
? – Leucomainehttp://myforecyte.com/dev/Ariana_Perez.jpg
the file you wish to have displayed? If so, try making it all lowercase. Sometimes servers play mean tricks with file conventions as such. I'm picking at straws here I know, but am trying to go byprocess of elimination
. – Leucomainevar_dump( );
? – Leucomainevar_dump();
for$message
and$cid
and show the results. – Leucomainetext/html
? – Leucomainedisplay_errors
, is it "on"? – LeucomaineUTF-8
, is itwith
orwithout
theBOM
? Am picking at another straw, but not leaving it out of the equation. I doubt it but worth a shot. – Leucomaine