Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I agree with @MihaiIorga in the comments – use the PHPMailer script. You sound like you're rejecting it because you want the easier option. Trust me, PHPMailer <strong>is</strong> the easier option by a very large margin compared to trying to do it yourself with PHP's built-in <code>mail()</code> function. PHP's <code>mail()</code> function really isn't very good.</p> <p>To use PHPMailer:</p> <ul> <li>Download the PHPMailer script from here: <a href="http://github.com/PHPMailer/PHPMailer" rel="nofollow noreferrer">http://github.com/PHPMailer/PHPMailer</a></li> <li>Extract the archive and copy the script's folder to a convenient place in your project.</li> <li>Include the main script file -- <code>require_once('path/to/file/class.phpmailer.php');</code></li> </ul> <p>Now, sending emails with attachments goes from being insanely difficult to incredibly easy:</p> <pre><code>use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; $email = new PHPMailer(); $email-&gt;SetFrom('you@example.com', 'Your Name'); //Name is optional $email-&gt;Subject = 'Message Subject'; $email-&gt;Body = $bodytext; $email-&gt;AddAddress( 'destinationaddress@example.com' ); $file_to_attach = 'PATH_OF_YOUR_FILE_HERE'; $email-&gt;AddAttachment( $file_to_attach , 'NameOfFile.pdf' ); return $email-&gt;Send(); </code></pre> <p>It's just that one line <code>$email-&gt;AddAttachment();</code> -- you couldn't ask for any easier.</p> <p>If you do it with PHP's <code>mail()</code> function, you'll be writing stacks of code, and you'll probably have lots of really difficult to find bugs.</p>
 

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