[英]Swiftmailer symfony2.2 always sent 0 emails
我有以下swiftmailes配置
# config.yml
swiftmailer:
transport: stmp
host: mail.domain.com
port: 25
username: myuser
password: mypass
spool:
type: file
path: "%kernel.cache_dir%/swiftmailer/spool"
logging: "%kernel.debug%"
和以下代碼發送消息
$subject = "TESTING";
$mailer = $this->getContainer()->get('mailer');
$message = \Swift_Message::newInstance()
->setSubject($subject)
->setFrom("noreply@domain.com")
->setTo("julian.reyes.escrigas@gmail.com")
->setBody("Body message");
$mailer->send($message);
發送消息后,可以在app/cache/dev/swiftmailer/spool
但是當我調用命令時
$ app/console swiftmailer:spool:send --message-limit=10 --env=dev
線軸中的所有消息均消失,但不會發送給接收者。
注意 :我已嘗試使用客戶端(雷鳥)進行STMP設置並正常工作
出於測試目的,我嘗試不經隊列直接發送消息
$message = \Swift_Message::newInstance()
->setSubject($subject)
->setFrom("noreply@domain.com")
->setTo("julian.reyes.escrigas@gmail.com")
->setBody("Body message");
$mailer->send($message);
$transport = $this->getContainer()->get('swiftmailer.transport.real');
$transport->start();
// but count alwasy is zero
$count = $transport->send($message);
我已經嘗試過config.yml文件中的每種組合
auth_mode: plain / login / null
encryption: tsl / ssl / null
port: 25 / 465
從symfony profiler我得到
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=utf-8
MIME-Version: 1.0
Date: Tue, 04 Jun 2013 14:33:12 -0500
Message-ID: <1370374392.51ae40f8b6202@localtest>
From: noreply@mydomain.com
Subject: TEST
To: julian.reyes.escrigas@gmail.com
Mensaje de prueba de Texto
我開始認為這可能與我安裝的版本有關。 我嘗試不成功直接創建SMTP傳輸
$message = \Swift_Message::newInstance()
->setSubject("TEST")
->setFrom("noreply@domain.com")
->setTo(array("julian.reyes.escrigas@gmail.com"))
->setBody("Mensaje de prueba de Texto");
$transport = \Swift_SmtpTransport::newInstance('mail.domain.com', 25)
->setUsername('noreply@domain.com')
->setPassword('THEPASS');
$mailer = \Swift_Mailer::newInstance($transport);
$transport->start();
// ZERO again
$output->writeln(sprintf("Mensajes enviados: %s", $mailer->send($message)));
注意2 :我已經嘗試使用PHpMailer並使用相同的設置毫無問題地發送郵件,但是我想使用swiftmailer
注意3 :在具有本地設置的托管服務提供商上進行測試可以正常工作。 但是我不能在不使用棘手的ssh隧道的情況下從自己的筆記本電腦(開發環境)進行測試
transport: mail
host: localhost
username: ~
password: ~
您確定這不僅是錯字嗎?
transport: stmp
=>
transport: smtp
如果有人尋找答案,請嘗試在setFrom()
方法中設置有效的電子郵件地址; 在我的情況下,假冒的電子郵件(例如“ noreply@domain.com”)被假脫機,但是傳遞失敗。 指定有效地址后,它發送了一封電子郵件(最后!)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.