开发者

How to send html email? [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. 开发者_开发技巧 Closed 10 years ago.

I need to send html email. So I am using PEAR library with Mail extension

So I have written this code:

include('Mail.php');
include('Mail/mime.php');

$email = "xxx@gmail.com";
$from_addr = "example <yyy@gmail.com>";
$message_subject ="Test";    
$text =  "
Hello.
This is a link:

http//:www.hardevent.net/index.php

byebye
";

$html = "<html>
<body>
<p>
Hellooooo, this is a link:
</p>
<a href=\"http://www.google.com\"/>Gooooo</a>
</body>
</html>";

                     $headers = array ("From" => $from_addr,
                                       "To" => $email,
                                       "Subject" => $message_subject);


                     $crlf = "\n";
                     $mime = new Mail_mime($crlf);
                     $mime->setTXTBody($text);
                     $mime->setHTMLBody($html);
                     $body = $mime->get();
                     $hdrs = $mime->headers($headers);
                     $smtp = Mail::factory("smtp", array ('host' => "smtp.xxx.com",
                                                          'auth' => true,
                                                          'username' => "xxx",
                                                          'password' => "xxx"));
                     $mail = $smtp->send($email, $hdrs, $body);

But this is the email that I see ( only text without link ):

Object: Test
Hellooooo, this is a link:

Gooooo

why ?


Typo?

<a href=\"http://www.google.com\">Gooooo</a>


You are closing the link:

<a href=\"http://www.google.com\"/>

The trailing / needs to be removed.


Try single quoting the link <a href='http://www.google.com'>Gooooo</a>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜