Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The following line get the contents of a HTML page.</p> <pre><code> $mail-&gt;MsgHTML(file_get_contents('contents.html')); </code></pre> <p>Go here for full details: <a href="http://phpmailer.worxware.com/index.php?pg=exampleagmail" rel="nofollow">http://phpmailer.worxware.com/index.php?pg=exampleagmail</a></p> <pre><code>require_once('../class.phpmailer.php'); //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch $mail-&gt;IsSMTP(); // telling the class to use SMTP try { $mail-&gt;Host = "mail.yourdomain.com"; // SMTP server $mail-&gt;SMTPDebug = 2; // enables SMTP debug information (for testing) $mail-&gt;SMTPAuth = true; // enable SMTP authentication $mail-&gt;SMTPSecure = "tls"; // sets the prefix to the servier $mail-&gt;Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail-&gt;Port = 587; // set the SMTP port for the GMAIL server $mail-&gt;Username = "yourusername@gmail.com"; // GMAIL username $mail-&gt;Password = "yourpassword"; // GMAIL password $mail-&gt;AddReplyTo('name@yourdomain.com', 'First Last'); $mail-&gt;AddAddress('whoto@otherdomain.com', 'John Doe'); $mail-&gt;SetFrom('name@yourdomain.com', 'First Last'); $mail-&gt;AddReplyTo('name@yourdomain.com', 'First Last'); $mail-&gt;Subject = 'PHPMailer Test Subject via mail(), advanced'; $mail-&gt;AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically $mail-&gt;MsgHTML(file_get_contents('contents.html')); $mail-&gt;AddAttachment('images/phpmailer.gif'); // attachment $mail-&gt;AddAttachment('images/phpmailer_mini.gif'); // attachment $mail-&gt;Send(); echo "Message Sent OK\n"; } catch (phpmailerException $e) { echo $e-&gt;errorMessage(); //Pretty error messages from PHPMailer } catch (Exception $e) { echo $e-&gt;getMessage(); //Boring error messages from anything else! } </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