How can I send an HTML-formatted email with pictures using PHP?
I want to have a page with some settings and HTML output which is sent via email to an address. What
I have a this code and it will run perfectly for my site
public function forgotpassword($pass,$name,$to)
{
$body ="";
$body .= " PMS Pvt Ltd.
";
$body .='
Dear '.$name.', ';
$body .= '
As per Your request we send Your Password.
Password is : '.$pass.' ';
$body .= '
If you have any questions, please feel free to contact us at:
support@pms.com ';
$body .= '
Best regards,
The PMS Team.
';
$subject = "Forgot Password";
$this->sendmail($body,$to,$subject);
}
mail function
function sendmail($body,$to,$subject)
{
//require_once 'init.php';
$from='testing@gmail.com';
$headersfrom='';
$headersfrom .= 'MIME-Version: 1.0' . "\r\n";
$headersfrom .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headersfrom .= 'From: '.$from.' '. "\r\n";
mail($to,$subject,$body,$headersfrom);
}
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.
function imageUrl()
{
return "http://".$_SERVER['SERVER_NAME'].substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], "/")+1)."images/capacity.jpg";
}