Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would strongly recommend using a library like <a href="https://github.com/PHPMailer/PHPMailer" rel="nofollow noreferrer">PHPMailer</a> to send emails.<br> It's easier and handles most of the issues automatically for you.</p> <p>Regarding displaying embedded (inline) images, here's what's on <a href="http://phpmailer.worxware.com/index.php?pg=tutorial#3.3" rel="nofollow noreferrer">their documentation</a>:</p> <blockquote> <p>Inline Attachments</p> <p>There is an additional way to add an attachment. If you want to make a HTML e-mail with images incorporated into the desk, it's necessary to attach the image and then link the tag to it. For example, if you add an image as inline attachment with the CID my-photo, you would access it within the HTML e-mail with <code>&lt;img src="cid:my-photo" alt="my-photo" /&gt;</code>.</p> <p>In detail, here is the function to add an inline attachment:</p> </blockquote> <pre><code>$mail-&gt;AddEmbeddedImage(filename, cid, name); //By using this function with this example's value above, results in this code: $mail-&gt;AddEmbeddedImage('my-photo.jpg', 'my-photo', 'my-photo.jpg '); </code></pre> <hr> <p>To give you a more complete example of how it would work:</p> <pre><code>&lt;?php require_once('../class.phpmailer.php'); $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;Port = 25; // set the SMTP port $mail-&gt;SetFrom('name@yourdomain.com', 'First Last'); $mail-&gt;AddAddress('whoto@otherdomain.com', 'John Doe'); $mail-&gt;Subject = 'PHPMailer Test'; $mail-&gt;AddEmbeddedImage("rocks.png", "my-attach", "rocks.png"); $mail-&gt;Body = 'Your &lt;b&gt;HTML&lt;/b&gt; with an embedded Image: &lt;img src="cid:my-attach"&gt; Here is an image!'; $mail-&gt;AddAttachment('something.zip'); // this is a regular attachment (Not inline) $mail-&gt;Send(); echo "Message Sent OK&lt;p&gt;&lt;/p&gt;\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! } ?&gt; </code></pre> <h3>Edit:</h3> <p>Regarding your comment, you asked how to send HTML <strong>email</strong> with embedded images, so I gave you an example of how to do that.<br> The library I told you about can send emails using a lot of methods other than SMTP.<br> Take a look at the <a href="http://phpmailer.worxware.com/index.php?pg=examples" rel="nofollow noreferrer">PHPMailer Example page</a> for other examples.</p> <p>One way or the other, if you don't want to send the email in the ways supported by the library, you can (should) still use the library to build the message, then you send it the way you want.</p> <p>For example:</p> <p>You can replace the line that send the email:</p> <pre><code>$mail-&gt;Send(); </code></pre> <p>With this:</p> <pre><code>$mime_message = $mail-&gt;CreateBody(); //Retrieve the message content echo $mime_message; // Echo it to the screen or send it using whatever method you want </code></pre> <p>Hope that helps. Let me know if you run into trouble using it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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