How to set #39;FROM#39; property using Swiftmailer with Gmail?(如何使用 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"属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 Swiftmailer 和 Gmail 设置“FROM"属性?


基础教程推荐
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- php中的foreach复选框POST 2021-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- Web 服务器如何处理请求? 2021-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- php中的PDF导出 2022-01-01
- 将变量从树枝传递给 js 2022-01-01