我安装了包括smtp在内的梨邮件
$ sudo pear install Net_SMTP
我的php看起来像这样
$mail = @ \Mail::factory('smtp', $params);
$mail = & $mail;
$success = $mail->send($this->vchEmail, $headers, $body);
if (!$success) {
throw new Exception(' Email was not sent.');
}
if (@\PEAR::isError($mail)) {
throw new Exception(' Email was not sent: '.$mail->getMessage());
}
它没有例外,但是mailtrap.io没有显示收到的电子邮件。
如果我从本地发送电子邮件,则会发送和接收,如下所示:
$mail = @ \Mail::factory('mail', $params);
可能是我安装Net_SMTP时遇到的问题。我得到了一些警告:
WARNING: channel "pear.php.net" has updated its protocols, use "pear channel-update pear.php.net" to update
WARNING: "pear/Auth_SASL" is deprecated in favor of "pear/Auth_SASL2"
Did not download optional dependencies: pear/Auth_SASL, use --alldeps to download automatically
pear/Net_SMTP can optionally use package "pear/Auth_SASL" (version >= 1.0.5)
downloading Net_SMTP-1.8.0.tgz ...
Starting to download Net_SMTP-1.8.0.tgz (14,399 bytes)
.....done: 14,399 bytes
downloading Net_Socket-1.2.2.tgz ...
Starting to download Net_Socket-1.2.2.tgz (6,903 bytes)
...done: 6,903 bytes
install ok: channel://pear.php.net/Net_Socket-1.2.2
install ok: channel://pear.php.net/Net_SMTP-1.8.0
我还检查了端口可用性如下:
安装Nmap $ sudo port install nmap
并检查端口25 $ nmap -p 25 smtp.mailtrap.io
这是结果
Starting Nmap 7.60 ( https://nmap.org ) at 2018-02-01 12:50 AEDT
Nmap scan report for smtp.mailtrap.io (34.197.182.80)
Host is up (0.23s latency).
Other addresses for smtp.mailtrap.io (not scanned): 52.5.224.12 34.224.48.59
rDNS record for 34.197.182.80: ec2-34-197-182-80.compute-1.amazonaws.com
PORT STATE SERVICE
25/tcp open smtp
Nmap done: 1 IP address (1 host up) scanned in 0.52 seconds
谢谢。