本文介绍了使用setReturnPath的Swiftmailer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过以下代码通过Amazon SES成功发送电子邮件,但是我试图设置返回路径,但它不起作用.当我使用-> setReturnPath('[email protected]')时,电子邮件根本不会发送.任何人都可以阐明其中的原因,或者知道如何使其正常工作吗?任何帮助都会很棒!

I am successully able to send emails via Amazon SES with the code below, but I am trying to set a return path and it doesnt work. When i use ->setReturnPath('[email protected]') the emails do not send at all. Can anyone shed some light why, or know how to get it to work?Any help would be great!

这是最新的swiftmailer(4.2.2)

This is the latest 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( '[email protected]' ) )
->setTo( array( '[email protected]' ) )
->setBody( $message_body, 'text/html' )
->addPart( "Please use a HTML compatible web browser to view this email.", 'text/plain' );

$mailer->send( $message );

推荐答案

您可以使用以下Swiftmailer函数:

You can use this Swiftmailer function:

$message = Swift_Message::newInstance();
$headers = $message->getHeaders();
$headers->addPathHeader('Your-Header-Name', '[email protected]');

这篇关于使用setReturnPath的Swiftmailer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 18:13