Send HTML in email via PHP

后端 未结 8 2235
时光说笑
时光说笑 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:30

    It is pretty simple, leave the images on the server and send the PHP + CSS to them...

    $to = 'bob@example.com';
    
    $subject = 'Website Change Reqest';
    
    $headers = "From: " . strip_tags($_POST['req-email']) . "\r\n";
    $headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
    $headers .= "CC: susan@example.com\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
    
    $message = '

    This is strong text while this is not.

    '; mail($to, $subject, $message, $headers);

    It is this line that tells the mailer and the recipient that the email contains (hopefully) well formed HTML that it will need to interpret:

    $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
    

    Here is the link I got the info.. (link...)

    You will need security though...

提交回复
热议问题