代码之家  ›  专栏  ›  技术社区  ›  Paulo Coghi

HTML电子邮件的头和MIME类型(通过PHP发送)

  •  0
  • Paulo Coghi  · 技术社区  · 15 年前

    对于仅包含HTML内容而不是混合类型(同时包含文本和HTML)的电子邮件,正确的邮件头信息和MIME类型是什么?

    我用的是Swiftmailer(PHP)来完成这项工作。

    1 回复  |  直到 15 年前
        1
  •  1
  •   joar    15 年前

    这是我的代码:

    $swift = new stdClass();
    $swift->transport = Swift_SendmailTransport::newInstance( '/usr/sbin/sendmail -bs' );
    $swift->mailer = Swift_Mailer::newInstance( $swift->transport );
    $swift->message = Swift_Message::newInstance('Title')
        ->setFrom( array('from@my.email' => 'Me') )
        ->setTo( array( 'to@some.one' => 'Some One' ) )
        ->setBody('<h1>It works!</h1>', 'text/html');
    

    您还可以查看 http://swiftmailer.org/docs/headers