如何使用 Swiftmailer 和 Gmail 设置“FROM"属性? [英] How to set 'FROM' property using Swiftmailer with Gmail?

查看:14
本文介绍了如何使用 Swiftmailer 和 Gmail 设置“FROM"属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?php
require_once 'lib/swift_required.php';
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
  ->setUsername('username@gmail.com')
  ->setPassword('password')
  ;
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance('HomeWork')
  ->setFrom(array('exampleFROM@gmail.com' => 'NAME'))
  ->setTo(array('exampleTO@gmail.com'=> 'NAME'))
  ->setBody('Test Message Body')
  ;
$mailer->send($message);
?>

它有效,但发件人是用户名@gmail.com".如何指定任何其他电子邮件地址以发送虚假电子邮件?

It works but sender is 'username@gmail.com'. How can I specify any other email address in order to send fake email?

推荐答案

Gmail 不允许覆盖 FROM 名称,但您向 gmail 证明您拥有的经过验证的电子邮件地址除外.选择其他电子邮件服务器或转到您的 gmail 设置并将其更改为另一个您可以接收电子邮件的有效电子邮件地址.

Gmail disallows overriding the FROM name except from verfied email addresses that you prove to gmail you own. Either choose a different email server or go to your gmail settings and change it to another valid email address that you can receive email from.

这篇关于如何使用 Swiftmailer 和 Gmail 设置“FROM"属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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