phpmailer连接被拒绝

phpmailer连接被拒绝,php,phpmailer,Php,Phpmailer,我无法使用PHPMailer发送电子邮件。我正在OSX(约塞米蒂)上运行MAMP(localhost:8888)。我按照[this][1]教程为MAMP版本的php全局设置了composer nano ~/.bash_profile alias phpmamp='/Applications/MAMP/bin/php/php5.4.34/bin/php' curl -sS https://getcomposer.org/installer | phpmamp sudo mv composer.ph

我无法使用PHPMailer发送电子邮件。我正在OSX(约塞米蒂)上运行MAMP(localhost:8888)。我按照[this][1]教程为MAMP版本的php全局设置了composer

nano ~/.bash_profile
alias phpmamp='/Applications/MAMP/bin/php/php5.4.34/bin/php'
curl -sS https://getcomposer.org/installer | phpmamp
sudo mv composer.phar /usr/local/bin/composer
composer
然后我在/Applications/MAMP/htdocs中创建了一个phpmailer目录

Composer.json:

然后在phpmailer目录中,我键入了一个命令composer install。它下载了文件,我在phpmailer目录中创建了一个index.php文件

从git获取依赖项后,文件结构如下所示:

  phpmailer
     |
     |----composer.json 
     |----vendor(directory with various subdirectories and files) 
     |----index.php
     |----composer.lock
调试日志:

2015-09-12 19:03:47连接:打开到ssl://localhost:25,timeout=300,options=array()2015-09-12 19:03:47 SMTP错误:无法连接到服务器:连接被拒绝(61)2015-09-12 19:03:47 SMTP连接()失败。https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 布尔(假)
PHP是一个很好的工具。因此,您应该更改以下两个调用:

$m->HOST = 'smtp.gmail.com';
$m->PORT = 465;

2015-09-12 19:03:47 Connection: opening to ssl://localhost:25, timeout=300, options=array ( ) 2015-09-12 19:03:47   SMTP ERROR: Failed to connect to server: Connection refused (61) 2015-09-12 19:03:47    SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting bool(false)
<?php
require_once 'vendor/autoload.php';
<?php
require_once 'vendor/autoload.php';

$m = new PHPMailer;
$m->SMTPDebug = 3;

$m = new PHPMailer;
$m->isSMTP();
$m->SMTPAuth = true;
$m->SMTPDebug = 2;
$m->HOST = 'smtp.gmail.com';
$m->Username = 'myemail@gmail.com';
$m->Password = 'hidden';
$m->SMTPSecure = 'ssl';
$m->PORT = 465;
$m->From = "myemail@gmail.com";
$m->FromName = "Android Plus Ios";
$m->addReplyTo('friend@gmail.com','Reply address');
$m->addAddress('friend@mdurohtak.ac.in','Rakesh');
$m->addCC('Jettu@hotmail.com', 'Jitesh');
$m->addBCC('Fudu@outlook.com', 'Fruity');
$m->Subject = "Please verify the account.";
$m->Body = 'Please click here to verify the account registration';
$m->AltBody = 'By Google';
var_dump($m->send());
?>
$m->HOST = 'smtp.gmail.com';
$m->PORT = 465;
$m->Host = 'smtp.gmail.com';
$m->Port = 465;