How can I send a HTML format email with pictures using PHP? I want to have a page with some settings and a HTML output which is sent via email to an address. What should I do? The main problem is to attach files.how can i do that?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Is there a way to play audio on a mobile browser w
The trick is to know the content id of the Image mime part when building the html body part. It boils down to making the img tag
https://github.com/horde/horde/blob/master/kronolith/lib/Kronolith.php
Look at the function buildMimeMessage for a working example.
Use PHPMailer,
To send HTML mail you have to set $mail->isHTML() only, and you can set your body with HTML tags
Here is a well written tutorial :
rohitashv.wordpress.com/2013/01/19/how-to-send-mail-using-php/
You need to code your html using absolute path for images. By Absolute path means you have to upload the images in a server and in the
src
attribute of images you have to give the direct path like this<img src="http://yourdomain.com/images/example.jpg">
.Below is the PHP code for your refference :- Its taken from http://www.php.net/manual/en/function.mail.php
You can easily send the email with HTML content via PHP. Use the following script.
Source code and live demo can be found from here - Send Beautiful HTML Email using PHP
I have a this code and it will run perfectly for my site
mail function
image url function is use for if you want to change the image you have change in only one function i have many mail function like forgot password create user there for i am use image url function you can directly set path.
Sending an html email is not much different from sending normal emails using php. What is necessary to add is the content type along the header parameter of the php mail() function. Here is an example.
You can also check here for more detailed explanations by w3schools