njdubois Posted October 14, 2013 Share Posted October 14, 2013 I have this code : $mail->addAddress("[email protected]", "bob"); $mail->Subject = "subject(PHPMailer test using MAIL)"; $body = <<<'EOT' BODY OF EMAIL EOT; I have a variable $email_message How do I replace BODY OF EMAIL with the contents of that variable? I've tried $mail->addAddress("[email protected]", "bob"); $mail->Subject = "subject(PHPMailer test using MAIL)"; $body = <<<'EOT' $email_message EOT; // AND $mail->addAddress("[email protected]", "bob"); $mail->Subject = "subject(PHPMailer test using MAIL)"; $body = <<<'EOT'$email_messageEOT; //AND $mail->addAddress("[email protected]", "bob"); $mail->Subject = "subject(PHPMailer test using MAIL)"; $body = <<<'EOT' ".$email_message." EOT; What one earth am I doing wrong? Many many Thanks!! Nick Link to comment https://forums.phpfreaks.com/topic/282967-insert-text-into-body-of-email-using-phpmailer/ Share on other sites More sharing options...
Barand Posted October 14, 2013 Share Posted October 14, 2013 How about $body = $email_message; Link to comment https://forums.phpfreaks.com/topic/282967-insert-text-into-body-of-email-using-phpmailer/#findComment-1453900 Share on other sites More sharing options...
DavidAM Posted October 14, 2013 Share Posted October 14, 2013 Now Doc Nowdocs are to single-quoted strings what heredocs are to double-quoted strings. A nowdoc is specified similarly to a heredoc, but no parsing is done inside a nowdoc. The construct is ideal for embedding PHP code or other large blocks of text without the need for escaping. It shares some features in common with the SGML <![CDATA[ ]]> construct, in that it declares a block of text which is not for parsing. A nowdoc is identified with the same <<< sequence used for heredocs, but the identifier which follows is enclosed in single quotes, e.g. <<<'EOT'. All the rules for heredoc identifiers also apply to nowdoc identifiers, especially those regarding the appearance of the closing identifier. (emphasis added) Try it without the single quotes (Here Doc) $body = <<<EOT $email_message EOT; Link to comment https://forums.phpfreaks.com/topic/282967-insert-text-into-body-of-email-using-phpmailer/#findComment-1453901 Share on other sites More sharing options...
njdubois Posted October 14, 2013 Author Share Posted October 14, 2013 $body = $email_message; worked perfectly! This Now Doc is completely new to me, and I am going to do some research cause I have seen this <<<EOT stuff before and it always confused me. Thanks everyone! Nick Link to comment https://forums.phpfreaks.com/topic/282967-insert-text-into-body-of-email-using-phpmailer/#findComment-1453903 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.