我可以使用下面的代码成功地通过 Amazon SES 发送电子邮件,但我正在尝试设置返回路径,但它不起作用。当我使用 ->setReturnPath('bounce@example.com') 时,电子邮件根本不会发送。任何人都可以解释为什么,或者知道如何让它工作吗?任何帮助都会很棒!
这是最新的 swiftmailer (4.2.2)
require_once 'lib/swift_required.php';
require_once 'classes/Swift/Transport/AWSTransport.php';
require_once 'classes/Swift/AWSTransport.php';
require_once 'classes/Swift/AWSInputByteStream.php';
define( 'AWSAccessKeyId', 'XXXXX' );
define( 'AWSSecretKey', 'XXXXX' );
//Create the Transport
$transport = Swift_AWSTransport::newInstance( AWSAccessKeyId, AWSSecretKey );
$transport->setDebug( true ); // Print's the response from AWS for debugging.
//Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance( $transport );
//Create the message
$message = Swift_Message::newInstance()
->setSubject( 'Sample Subject' )
->setFrom( array( 'test@example.com' ) )
->setTo( array( 'to@someone.com' ) )
->setBody( $message_body, 'text/html' )
->addPart( "Please use a HTML compatible web browser to view this email.", 'text/plain' );
$mailer->send( $message );