wp_mail在使用MAMP的本地主机上不起作用 [英] wp_mail not working on localhost with MAMP

查看:62
本文介绍了wp_mail在使用MAMP的本地主机上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用wp_mail函数向自己发送电子邮件,由于某种原因,我无法使其正常工作。有人可以帮我吗?

I'm trying to get the wp_mail function to send myself an email and for some reason I can't get it to work. Can anyone help me please?

这是我的基本脚本...

This is my basic script...

$to = "someone@gmail.com";
$subject = 'wp_mail function test';
$message = 'This is a test of the wp_mail function: wp_mail is working';
$headers = "From: Blog Name <admin@myemail.com> \r\n";

if ( $sent = wp_mail( $to, $subject, $message, $headers ) )
    echo 'The test message was sent. Check your email inbox.';
else
    echo 'The message was not sent!';

如果我是var_dump($ phpmailer),则得到以下内容...

If I var_dump($phpmailer) then I get the below...

object(PHPMailer)[288]
  public 'Priority' => int 3
  public 'CharSet' => string 'UTF-8' (length=5)
  public 'ContentType' => string 'text/plain' (length=10)
  public 'Encoding' => string '8bit' (length=4)
  public 'ErrorInfo' => string '' (length=0)
  public 'From' => string 'admin@myemail.com' (length=17)
  public 'FromName' => string 'Blog Name' (length=9)
  public 'Sender' => string '' (length=0)
  public 'ReturnPath' => string '' (length=0)
  public 'Subject' => string 'wp_mail function test' (length=21)
  public 'Body' => string 'This is a test of the wp_mail function: wp_mail is working' (length=58)
  public 'AltBody' => string '' (length=0)
  protected 'MIMEBody' => string 'This is a test of the wp_mail function: wp_mail is working
' (length=59)
  protected 'MIMEHeader' => string 'Date: Fri, 7 Mar 2014 15:19:55 +0000
Return-Path: admin@myemail.com
From: Blog Name <admin@myemail.com>
Message-ID: <ebf10bab4b57a811f54fe004e70a5a73@tp.dev>
X-Priority: 3
X-Mailer: PHPMailer 5.2.4 (http://code.google.com/a/apache-extras.org/p/phpmailer/)
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8
' (length=346)
  protected 'mailHeader' => string 'To: someone@gmail.com
Subject: wp_mail function test
' (length=53)
  public 'WordWrap' => int 0
  public 'Mailer' => string 'mail' (length=4)
  public 'Sendmail' => string '/usr/sbin/sendmail' (length=18)
  public 'UseSendmailOptions' => boolean true
  public 'PluginDir' => string '' (length=0)
  public 'ConfirmReadingTo' => string '' (length=0)
  public 'Hostname' => string '' (length=0)
  public 'MessageID' => string '' (length=0)
  public 'MessageDate' => string '' (length=0)
  public 'Host' => string 'localhost' (length=9)
  public 'Port' => int 25
  public 'Helo' => string '' (length=0)
  public 'SMTPSecure' => string '' (length=0)
  public 'SMTPAuth' => boolean false
  public 'Username' => string '' (length=0)
  public 'Password' => string '' (length=0)
  public 'AuthType' => string '' (length=0)
  public 'Realm' => string '' (length=0)
  public 'Workstation' => string '' (length=0)
  public 'Timeout' => int 10
  public 'SMTPDebug' => boolean false
  public 'Debugoutput' => string 'echo' (length=4)
  public 'SMTPKeepAlive' => boolean false
  public 'SingleTo' => boolean false
  public 'SingleToArray' => 
    array (size=0)
      empty
  public 'LE' => string '
' (length=1)
  public 'DKIM_selector' => string '' (length=0)
  public 'DKIM_identity' => string '' (length=0)
  public 'DKIM_passphrase' => string '' (length=0)
  public 'DKIM_domain' => string '' (length=0)
  public 'DKIM_private' => string '' (length=0)
  public 'action_function' => string '' (length=0)
  public 'Version' => string '5.2.4' (length=5)
  public 'XMailer' => string '' (length=0)
  protected 'smtp' => null
  protected 'to' => 
    array (size=1)
      0 => 
        array (size=2)
          0 => string 'someone@gmail.com' (length=17)
          1 => string '' (length=0)
  protected 'cc' => 
    array (size=0)
      empty
  protected 'bcc' => 
    array (size=0)
      empty
  protected 'ReplyTo' => 
    array (size=0)
      empty
  protected 'all_recipients' => 
    array (size=1)
      'someone@gmail.com' => boolean true
  protected 'attachment' => 
    array (size=0)
      empty
  protected 'CustomHeader' => 
    array (size=0)
      empty
  protected 'message_type' => string 'plain' (length=5)
  protected 'boundary' => 
    array (size=3)
      1 => string 'b1_ebf10bab4b57a811f54fe004e70a5a73' (length=35)
      2 => string 'b2_ebf10bab4b57a811f54fe004e70a5a73' (length=35)
      3 => string 'b3_ebf10bab4b57a811f54fe004e70a5a73' (length=35)
  protected 'language' => 
    array (size=0)
      empty
  protected 'error_count' => int 0
  protected 'sign_cert_file' => string '' (length=0)
  protected 'sign_key_file' => string '' (length=0)
  protected 'sign_key_pass' => string '' (length=0)
  protected 'exceptions' => boolean true    

它始终表示已发送电子邮件,但从未收到过电子邮件。

It always says that the email is sent yet no email ever arrives.

希望有人可以帮助我!

推荐答案

我总是使用 WP Mail SMTP 插件,并将其配置为通过我在本地主机上的gmail帐户发送电子邮件,然后我开始生产时,只删除了插件。

I always use the WP Mail SMTP plugin and configure it to send e-mail through my gmail account on localhost and then when I move to production, I just remove the plugin.

这篇关于wp_mail在使用MAMP的本地主机上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆