经过3周的搜索,我找到了这个很好的答案>>如何用链接替换普通URL?
但我不知道如何将其与phpmailer一起使用。。
我使用html表单将信息发送到电子邮件。某些电子邮件服务无法将url视为链接。我需要做的是,我是phpmailer的新手。
我希望这个网站是寻求答案的最佳场所。非常感谢。
用您创建的类扩展phpmailer
<?php
CLASS url_free_phpmailer EXTENDS phpmailer {
/**
* Replaces urls before sending
*
*/
public function Send() {
$this->Body = replace_urls($this->Body);
return call_user_func_array('parent::'.__FUNCTION__, func_get_args());
}
}
或者只是
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->From = "from@example.com";
$mail->AddAddress("myfriend@example.net");
$mail->Subject = "First PHPMailer Message";
# replace urls before setting
$mail->Body = replace_urls($body);
$mail->WordWrap = 50;
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
?>