Note that there are some explanatory texts on larger screens.

plurals
  1. POPHPMailer with textarea form and html
    text
    copied!<p>i'm trying to bit together some code from a php tutorial that shows how to make a very basic PHPMailer form that sends a plain text email to a mailing list. The simplicity is exactly what I want for the most part since a couple of people will be using this form, though I want to include the capability to use HTML in the form. So if for example, I want to use <code>&lt;center&gt;</code> tags or insert a hosted image <code>&lt;img src="www.link.com/img.jpg"&gt;</code> to make the email a bit more rich. </p> <p>At the moment, i'm not able to figure out how to enable the html embedding. If I put the HTML code into a form, it simply just outputs the code as such <code>&lt;b&gt;&lt;i&gt;text&lt;/i&gt;&lt;/b&gt;</code> where as I want the email to be displayed as just: <b><i>text</i></b></p> <p>I was thinking it could be the <code>IsHTML(True);</code> variable but everything seems to work fine when I send emails out. If I get rid of the <code>&lt;input type</code> and change it to say <code>&lt;span</code>then the email message is just blank.</p> <p>here is the original code I am working off of: <a href="http://yorkspace.wordpress.com/simple-php-mailing-list/" rel="nofollow">http://yorkspace.wordpress.com/simple-php-mailing-list/</a></p> <p>here is the sendmail.php, which is where one goes to edit the message, preview, then send:</p> <pre><code>&lt;?php require "maillist-settings.inc.php"; if ($_POST['preview']) { $email_array = $_POST['emaillist']; if (is_array($email_array)) { $subject = $_POST['emailtitle']; $message = $_POST['emailmessage']; $bcc_list = implode(", ", $email_array); echo "&lt;table&gt;&lt;tr&gt;&lt;td&gt;"; echo "&lt;form action=\"" . $_SERVER['SCRIPT_URL'] . "\" method=\"POST\"&gt;"; foreach ($email_array as $email_address) { echo "&lt;input type=\"hidden\" name=\"emaillist[]\" value=\"" . $email_address . "\"&gt;"; } echo "&lt;input type=\"hidden\" name=\"emailtitle\" value=\"" . $subject . "\"&gt;"; echo "&lt;input type=\"hidden\" name=\"emailmessage\" value=\"". $message ."\"&gt;"; echo "&lt;input type=\"submit\" name=\"sendemail\" value=\"Send Email\"&gt;&lt;/form&gt;"; echo "&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;"; } else if ($_POST['sendemail']) { LoadLib_PHPMailer(); $mail = new MLMail; $email_array = $_POST['emaillist']; if ( is_array($email_array) == TRUE ) { $mail-&gt;AddAddress($mail-&gt;From); $mail-&gt;Subject = stripslashes($_POST['emailtitle']); $mail-&gt;Body = stripslashes($_POST['emailmessage']); if(!$mail-&gt;Send()) echo "There has been an error sending email:&lt;br&gt;&lt;br&gt;&lt;b&gt;" . $mail-&gt;ErrorInfo . "&lt;/b&gt;"; else echo "Message has been sent successfully.&lt;br&gt;&lt;br&gt;&lt;a href=\"" . $_SERVER['SCRIPT_URL'] . "\"&gt;Send another message&lt;/a&gt;"; $mail-&gt;ClearAddresses(); } } else { $sEditSubject = $_POST['emailtitle']; if (isset($sEditSubject)) $subject = $sEditSubject; else $subject = ""; $sEditMessage = $_POST['emailmessage']; if (isset($sEditMessage)) $message = $sEditMessage; else { $message = "\n\n\n&lt;br&gt;FOOTER&lt;/BR&gt;\n\n"; } echo "Subject:"; echo "&lt;br&gt;&lt;input type=\"text\" name=\"emailtitle\" size=\"80\" value=\"" . htmlspecialchars(stripslashes($subject)) . "\"&gt;&lt;/input&gt;"; echo "&lt;br&gt;Message:"; echo "&lt;br&gt;&lt;textarea name=\"emailmessage\" rows=\"20\" cols=\"72\"&gt;" . htmlspecialchars(stripslashes($message)) . "&lt;/textarea&gt;"; echo "&lt;br&gt;&lt;input type=\"submit\" name=\"preview\" value=\"Preview\"&gt;&lt;/form&gt;"; } ?&gt; </code></pre> <p>and this is the maillist-settings.inc.php which is called from the sendmail.php</p> <pre><code>&lt;?php $listname = "Mailing List"; $listfile = "list.csv"; $sPHPMAILER_PATH = "phpmailer"; $sProtocol = "http://"; $sReferrer = "index.php"; $bEmailSend = true; $sSendType = "smtp"; $sFromEmailAddress = "email@email.com"; $sFromName = "my name"; $sSMTPHost = "mail.smtp.com"; $sSMTPAuth = true; $sSMTPUser = "email@email.com"; $sSMTPPass = "password"; $iSMTPPort = 25; $ishtml = true; require $sPHPMAILERpath . "class.phpmailer.php"; require $sPHPMAILERpath . "class.smtp.php"; // Define parameters as class MLMail class MLMail extends PHPMailer { // Set default variables for all new objects var $From; var $FromName; var $Mailer; var $IsHtml; var $WordWrap; var $Host; var $SMTPAuth; var $Username; var $Password; var $Port; function MLMail() { parent::SetLanguage('en','phpmailer/language/'); $this-&gt;From = $GLOBALS['sFromEmailAddress']; $this-&gt;FromName = $GLOBALS['sFromName']; $this-&gt;Mailer = $GLOBALS['sSendType']; $this-&gt;IsHtml = $GLOBALS['ishtml']; $this-&gt;WordWrap = $GLOBALS['sWordWrap']; if ($this-&gt;Mailer == "smtp") { $this-&gt;Port = $GLOBALS['iSMTPPort']; $this-&gt;Host = $GLOBALS['sSMTPHost']; $this-&gt;SMTPAuth = $GLOBALS['sSMTPAuth']; if ($this-&gt;SMTPAuth) { $this-&gt;Username = $GLOBALS['sSMTPUser']; $this-&gt;Password = $GLOBALS['sSMTPPass']; } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload