我创建了这个用于发送电子邮件的PHP类
class Mailbox{
private $mail;
public function initialize(){
$this->mail = new PHPMailer;
$this->mail->Mailer = "smtp.gmail.com";
$this->mail->Host = "mail.****.***.*g";
$this->mail->Port = 587;
$this->mail->IsSMTP(); // telling the class to use SMTP
$this->mail->SMTPAuth = true; // turn on SMTP authentication
$this->mail->SMTPSecure = "ssl";
$this->mail->Username = '****@******.com';
$this->mail->Password = '67******!'; // SMTP password
$this->mail->SetFrom('****@******.com', 'Federal Admin');
}
public function addSubject($sub='***** testing mail...'){
$this->mail->Subject = $sub;
$this->mail->AltBody = "...just a sample message";
}
public function addMessage($msg){
$this->mail->MsgHTML($msg);
}
public function addAddress($addr){
foreach($addr as $ad){
$this->mail->AddAddress($ad[0], $ad[1]);
}
}
public function send(){
if(!$this->mail->Send()) {
return "Mailer Error: mail not sent.." . $this->mail->ErrorInfo;
} else {
return true;
}
}
}
这是我在代码中的实现......
$ar = array(
['****r@k**g.gov', 'Recruit'],
['an***i@aol.com','Officer'],
['***iii@gmail.com','Secretary']
);
$message = $msg->render(); //renders a htmlview
$m = new Mailbox;
$m->initialize();
$m->addSubject('Reports from my store Armory');
$m->addMessage($message);
$m->addAddress($ar);
if($m->send()){
echo 'messsage sent successfully';
}else{
echo 'error sending message';
}
它正在三天前工作,周二恰好,下面的图片是我的aol邮件的输出,但就在最近,自周三以来,它还没有正常运行。我没有接触或改变任何东西,我已经迷失了,并且绕圈子走了。拜托,我需要帮助。有谁知道GMail是否有任何问题或是否有人遇到与我相同的问题..
如果有人解决了这个问题,我需要帮助,我的猜测是Gmail有问题,我已经更改了允许不安全的应用程序设置,但我仍然不断收到这些错误。
答案 0 :(得分:1)
key = proc { |x| [x[:name], x[:nationality]] }
merge = proc { |x, y| x.dup.tap { |x1| x1[:age] += y[:age] } }
result = array.each_with_object({}) do |x, hsh|
if hsh.include? key[x]
hsh[ key[x] ] = merge.call hsh[ key[x] ], x
else
hsh[ key[x] ] = x
end
end.values
{SSL {1}}
检查一下! http://www.tutsplanet.com/send-email-using-smtp-server-phpmailer-997/