首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHP邮件函数错误- Olia Studio

PHP邮件函数错误- Olia Studio
EN

Stack Overflow用户
提问于 2015-05-12 17:39:27
回答 1查看 426关注 0票数 0

我不拥有“油茶工作室”,但我很了解拥有它的人。当我试图通过网站向她发送电子邮件(消息)时,我遇到了一大堆错误。这是一家新公司,业主现在不需要这些问题,有什么帮助吗?

以下是错误:

代码语言:javascript
复制
Strict Standards: Non-static method Mail::factory() should not be called statically in /home/liveolia/public_html/health-and-fitness-contact-us.php on line 35

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Mail/smtp.php on line 365

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 448

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 465

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 472

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 515

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 263

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 519

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Mail/smtp.php on line 376

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 597

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 263

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 600

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 603

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 515

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 263

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 519

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 621

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 802

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 263

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 806

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 814

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 263

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 818

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 822

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 263

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 827

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 649

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Mail/smtp.php on line 249

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Mail/smtp.php on line 285

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 945

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 263

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 948

Strict Standards: Non-static method Mail_RFC822::parseAddressList() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Mail.php on line 254

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 975

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 263

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 978

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 1054

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 263

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 1057

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 1117

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 263

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 1127

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 263

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 1132

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 489

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 263

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 492

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/liveolia/public_html/libraries/Net/SMTP.php on line 495

Warning: Cannot modify header information - headers already sent by (output started at /home/liveolia/public_html/health-and-fitness-contact-us.php:35) in /home/liveolia/public_html/health-and-fitness-contact-us.php on line 38

该网站是oliastudio.co.uk -帮助是需要的!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-05-12 19:02:40

最后找到了这个例子。我建议从梨转到Mail2。它不会抛出异常。我的示例还使用MIME来正确格式化消息。我不想依赖于我的SMTP中继,所以我直接将邮件推送给收件人MX记录。如果这样做,请确保SPF记录具有服务器的aip4标志。像$name$mail这样的细节是在脚本的另一部分中从DB中提取出来的。你的就不一样了。

示例代码:

代码语言:javascript
复制
<?php
include 'Mail2.php';
include 'Mail/mime.php';

function getMX($email){
     $mailparts = explode('@', $email);
     $hostname = $mailparts[1];
     $b_mail_avail = getmxrr( $hostname, $mx_records, $mx_weights );
     if($b_mail_avail){
          return $mx_records[0];
     } else {
          return false;
     }
}

$subject = "Reset Example Password Request";

$txtparams = array(
     'charset' => 'utf-8',
     'content_type' => 'text/plain',
     'encoding' => 'quoted/printable'
);

$txtMessage  = "Hello $name,\n";
$txtMessage .= "A request to reset your Password has been initiated.\n";
$txtMessage .= "To complete this, please follow the link below.\n\n";
$txtMessage .= "http://www.example.com/admin/admin-login.php?a=confirm&c=$c\n\n";
$txtMessage .= "If you did not request to reset your password, follow this link below.\n\n";
$txtMessage .= "http://www.exmaple.com/admin/admin-login.php?a=deny&c=$c\n\n";

$htmlparams = array(
     'charset' => 'utf-8',
     'content_type' => 'text/html',
     'encoding' => 'quoted/printable'
);
$htmlMessage  = "<html><body><p>Hello $name,</p>\n";
$htmlMessage .= "<p>A request to reset your Password has been initiated.</p>\n";
$htmlMessage .= "<p>To complete this, please follow the link below.<br><br>\n";
$htmlMessage .= "<a href='http://www.exmaple.com/admin/admin-login.php?a=confirm&c=$c'>http://www.exmaple.com/admin/admin-login.php?a=confirm</a>\n";
$htmlMessage .= "If you did not request to reset your password, follow this link below.<br><br>\n";
$htmlMessage .= "<a href='http://www.exmaple.com/admin/admin-login.php?a=deny&c=$c'>http://www.exmaple.com/admin/admin-login.php?a=deny&c=$c</a>\n";
$htmlMessage .= "</body></html>";

$headers  = array(
     "To" => "$name <$mail>",
     "From" => "webmaster@exmaple.com",
     "Reply-To" => "donotreply@example.com",
     "Subject" => $subject,
     "X-Request-Address" => $_SERVER['REMOTE_ADDR'],
     "Content-Type" => "text/html; charset=UTF-8"
);

$mime_params = array(
     'text_encoding' => '7bit',
     'text_charset' => 'UTF-8',
     'html_charset' => 'UTF-8',
     'head_charset' => 'UTF-8'
);
$mime = new Mail_mime();

$mime->setTXTBody($txtMessage);
$mime->setHTMLBody($htmlMessage);

$body = $mime->get($mime_params);
$hdrs = $mime->headers($headers);

$hostname = getMX($email);
if($hostname){
     $mail = Mail2::factory('smtp',
          array(
               'host' => $hostname,
               'auth' => false
          )
     );

     // Send Email
     $sm = $mail->send("$name <$email>", $hdrs, $body);
     if(PEAR::isError($sm)){
          $smtpError = $sm->getMessage();
          // Do error handling stuff
     }
}
?>

希望这会有所帮助,您可以配置如下所述的其他邮件方法:http://pear.php.net/package/Mail2/docs/latest/Mail/Mail2.html

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30197887

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档