Send HTML in email via PHP

后端 未结 8 2093
时光说笑
时光说笑 2020-11-22 03:13

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

8条回答
  •  无人及你
    2020-11-22 03:28

    I have a this code and it will run perfectly for my site

      public function forgotpassword($pass,$name,$to)
        {
            $body ="";
            $body .='';
            $body .= '';
            $body .= '';
            $body .= '
    "; $body .= "

    PMS Pvt Ltd.




    Dear '.$name.',

    As per Your request we send Your Password.

    Password is : '.$pass.'

    If you have any questions, please feel free to contact us at:
    support@pms.com


    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";
        }
    

提交回复
热议问题