请原谅我的 php,但我使用 Swiftmailer 从客户网站发送电子邮件。他们要求添加一两个图像作为签名等,因此请查看此处的 swiftmailer 规范
http://swiftmailer.org/docs/messages.html
他们建议添加这样的内联图像
$message->embed(Swift_Image::fromPath('http://site.tld/image here'))
或像这样(分两步)
$cid = $message->embed(Swift_Image::fromPath('image here'));
然后在电子邮件正文部分添加
<img src="' . $cid . '" alt="Image" />'
这两个步骤我都试过了,但都无济于事。当我点击发送电子邮件按钮时,我收到了这个错误,我不知道该怎么做。
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
我添加到我已经工作的代码和电子邮件中的唯一内容是直接来自文档页面中示例的图像代码。此错误显然会阻止发送电子邮件。如果我删除它然后它发送电子邮件罚款。由于我需要为此添加图像,
任何帮助是极大的赞赏。谢谢
编辑:这是构建和发送电子邮件的部分 $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')
;