标签: swiftmailer

给定[]的邮箱中的地址不符合RFC 2822,3.6.2.当电子邮件在变量中时

我有一个正确的电子邮件地址.我已经回应了它.但是当我发送它时,我收到以下错误:

 Address in mailbox given [] does not comply with RFC 2822, 3.6.2. 
Run Code Online (Sandbox Code Playgroud)

为什么?我使用laravel(swift mailer)发送电子邮件.

$ email = email@address.com

然后当我发送它时,错误被抛出.

但如果我直接使用该字符串,它会发送它.

这是块:

$email = email@address.com
Run Code Online (Sandbox Code Playgroud)

php email swiftmailer laravel laravel-4

25
推荐指数
5
解决办法
8万
查看次数

PHP Swift邮件程序:无法使用2个可能的身份验证器在SMTP上进行身份验证

当我将带有PHP Swift邮件程序的电子邮件发送到此服务器时:smtp.exchange.example.com如下:

// Load transport
$this->transport =
    Swift_SmtpTransport::newInstance(
       self::$config->hostname,
       self::$config->port
    )
    ->setUsername(self::$config->username)
    ->setPassword(self::$config->password)
    ;

// Load mailer
$this->mailer = Swift_Mailer::newInstance($this->transport);

// Initialize message
$this->message = Swift_Message::newInstance();

// From
$this->message->setFrom(self::$config->from);

// Set message etc. ...

// Send
$this->mailer->send($this->message);
Run Code Online (Sandbox Code Playgroud)

我收到一个奇怪的错误:

无法使用2个可能的身份验证器在用户名为"user@example.com"的SMTP服务器上进行身份验证

我确定登录信息是正确的.

php authentication smtp swiftmailer

24
推荐指数
4
解决办法
9万
查看次数

HTML与纯文本作为电子邮件中的正文

创建时,Swift_Message您可以同时拥有纯文本和电子邮件的html版本.您将一个设置为正文,然后将另一个添加为部分.

如果我将HTML版本设置为正文和纯文本作为一部分,那么有什么区别?

$html_as_body = Swift_Message::newInstance()
    ->setSubject($subject)
    ->setBody($html, 'text/html')
    ->addPart($plain, 'text/plain');

$plain_as_body = Swift_Message::newInstance()
    ->setSubject($subject)
    ->setBody($plain, 'text/plain')
    ->addPart($html, 'text/html');
Run Code Online (Sandbox Code Playgroud)

差异化,我的意思是它在电子邮件阅读器中会有什么样的差异呢?

html plaintext swiftmailer

23
推荐指数
1
解决办法
2万
查看次数

Symfony 3.3和Swiftmailer - 由服务器延迟的控制器创建和发送的邮件

我正在尝试使用Swiftmailer从网站发送电子邮件.由于Swiftmailer尝试使用我服务器的IP地址而不是localhost作为中继,因此电子邮件不断延迟:

Aug  2 14:18:28 picus sm-mta[21171]: v72IIS0I021171: from=<Test@test.com>, size=347, class=0, nrcpts=1, msgid=<91d4a1a70de9fed0a2c04e682e435405@swift.generated>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Aug  2 14:18:28 picus sm-mta[21173]: v72IIS0I021171: to=<person@gmail.com>, delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=120347, relay=example.com. [my.servers.ip.address], dsn=4.0.0, stat=Deferred: Connection refused by example.com.
Run Code Online (Sandbox Code Playgroud)

我的Symfony控制器代码,配​​置和参数 -

相关控制器代码:

if ($form->isSubmitted() && $form->isValid()) {
    $data = $form->getData();

    $this->addFlash('success', 'Message sent successfully');

    $data['message'] = str_replace("\n.", "\n..", $data['message']);

    $mail = (new \Swift_Message())
        ->setSubject("[From My Website] - {$data['subject']}")
        ->setFrom($data['email'])
        ->setTo('person@gmail.com')
        ->setBody("{$data['name']} wrote the following message:\n\n{$data['message']}");

    $this->get('mailer')->send($mail);

    return $this->redirect($this->generateUrl('_home'));
}
Run Code Online (Sandbox Code Playgroud)

config.yml:

# Swiftmailer Configuration …
Run Code Online (Sandbox Code Playgroud)

php email swiftmailer symfony

22
推荐指数
2
解决办法
2611
查看次数

如何将完整的URL添加到Symfony2发送的简报中?

我将使用Symfony2定期向许多用户发送简报.我要为那些在使用电子邮件客户端阅读时遇到问题的人提供HTML电子邮件的固定链接.

无论如何,假设我以这种方式发送简报:

// Assume success and create a new SentMessage to store and get permalink
$sent = new SentMessage();

$sent->setRecipients(/* ... */);
$sent->setSubject(/* ... */);
$sent->setContent(/* ... */);

// Get the slug for the new sent message
$slug = $sent->getSlug(); // Like latest-product-offers-546343

// Construct the full URL
// e.g. http://mydomain.com/newsletter/view/latest-product-offers-546343

// Actually send a new email
$mailer->send(/* .. */);
Run Code Online (Sandbox Code Playgroud)

如何构建完整的URL(域+控制器+动作+ slug)以将其包含在新电子邮件中?

url permalinks swiftmailer symfony

20
推荐指数
3
解决办法
1万
查看次数

Symfony2 Swiftmailer没有发送

我在使用symfony2和swiftmailer发送电子邮件时遇到问题.我对如何调试此问题也有点迷失.下面是代码.首先,我正在创建一个要显示的表单.在提交(request-> method == post)后,我尝试发送电子邮件.我没有收到任何错误,它将我带到了谢谢你的页面,但是,我没有收到任何电子邮件.我已经测试了prod和dev.在开发中,我在提交后打开了探查器,它显示了0封电子邮件.任何帮助表示赞赏!谢谢!

public function contactAction(Request $request)
{
    $defaultData = array('name' => 'Name', 'email' => 'Email', 'subject' => 'Subject', 'message' => 'Message');
    $form = $this->createFormBuilder($defaultData)
        ->add('name', 'text')
        ->add('email', 'email')
        ->add('subject', 'text')
        ->add('message', 'textarea')
        ->getForm();

    if($request->getMethod() == 'POST') {
        $form->bindRequest($request);
        $data = $form->getData();
        $message = \Swift_Message::newInstance()
            ->setSubject($data['subject'])
            ->setFrom('no-reply@mysite.com')
            ->setTo('email@mysite.com')
            ->setBody($this->renderView('AdaptiveSiteBundle:Default:email.txt.twig', array('name' => $data['name'], 'message' => $data['message'])))
        ;
        $this->get('mailer')->send($message);

        return $this->redirect($this->generateUrl('thankyou'));
    } 

    return array("form" => $form->createView());
}
Run Code Online (Sandbox Code Playgroud)

swiftmailer symfony

19
推荐指数
5
解决办法
4万
查看次数

如何在不使用视图的情况下向Laravel 4发送电子邮件?

我正在使用Laravel 4开发一个网站,并希望在测试期间发送自己的临时电子邮件,但似乎发送电子邮件的唯一方法是通过视图.

可以这样做吗?

Mail::queue('This is the body of my email', $data, function($message)
{
    $message->to('foo@example.com', 'John Smith')->subject('This is my subject');
});
Run Code Online (Sandbox Code Playgroud)

php email swiftmailer laravel

19
推荐指数
2
解决办法
1万
查看次数

Swiftmailer:无法与主机smtp.gmail.com建立连接[连接超时#110]

我发帖是因为我已经完成了其他问题的解决方案,但他们没有帮助.

我想要做的是通过Google Apps for Business Gmail使用Swiftmailer发送电子邮件,但我一直收到此错误:

无法通过主机smtp.gmail.com建立连接[连接超时#110]

我知道代码很好,因为它可以在我的本地机器上运行,但不能在生产服务器上运行.

到目前为止我尝试了什么:

  • 启用OpenSSL.
  • 来自Google验证码的未屏蔽帐户.
  • 使用应用程序专用密码.
  • 列入白名单的Gmail SMTP IP地址

组态:

# Swiftmailer Configuration
swiftmailer:
    transport:  smtp
    encryption: ssl
    auth_mode:  login
    host:       smtp.gmail.com
    username:   contact@mydomain.com
    password:   applicationspecificpassword
    port:       465
Run Code Online (Sandbox Code Playgroud)

我还能尝试什么?这可能是一个DNS问题,因为我使用的是Gmails SMTP MX记录而不是服务器.

php email swiftmailer symfony

18
推荐指数
3
解决办法
7万
查看次数

通过Laravel使用gmail smtp:无法与主机smtp.gmail.com建立连接[连接超时#110]

当我尝试使用GMail SMTP通过Laravel发送电子邮件时,我遇到以下错误:

Swift_TransportException

Connection could not be established with host smtp.gmail.com [Connection timed out #110]
Run Code Online (Sandbox Code Playgroud)

这是错误的痕迹:

...
 }
$this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, stream_context_create($options));
if (false === $this->_stream) {
throw new Swift_TransportException(
'Connection could not be established with host ' . $this->_params['host'] .
' [' . $errstr . ' #' . $errno . ']'...
Run Code Online (Sandbox Code Playgroud)

这是我的邮件配置:

'driver' => 'smtp',

'host' => 'smtp.gmail.com',

'port' => 587,

'from' => array('address' => 'some@example.ir', 'name' => 'some'),

'encryption' => 'tls',

'username' => 'myemail@gmail.com', …
Run Code Online (Sandbox Code Playgroud)

smtp swiftmailer laravel-4

18
推荐指数
6
解决办法
8万
查看次数

使用gmail无法在SMTP服务器上进行身份验证

我正在尝试为我的第一个laravel项目设置电子邮件,并且很高兴它有一个laracast:https://laracasts.com/lessons/mailers

我按照简单的步骤,在mail.php中选择了gmail(x为匿名添加):

'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => 'dianexxxxx@gmail.com', 'name' => 'Diane Kaplan'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => 'dianexxxxx@gmail.com',
'password' => 'xxxxx',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
Run Code Online (Sandbox Code Playgroud)

.env有(x是为匿名添加的) - laracast没有我们使用MAIL_USERNAME和MAIL_PASSWORD,但是它们已经更新了,假设我稍后会从那里拉出来:

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=dianexxxxx@gmail.com
MAIL_PASSWORD=xxxxxx
MAIL_ENCRYPTION=null
Run Code Online (Sandbox Code Playgroud)

但在尝试发送邮件(3:30标记)的第一个小时刻,我收到一个身份验证错误:AuthHandler.php第181行中的Swift_TransportException:无法使用用户名"dianexxxxx@gmail.com"在SMTP服务器上进行身份验证3个可能的验证者

基于一点stackoverflow读取,我尝试在我的Gmail设置中启用"访问不太安全的应用程序",但错误没有变化.(而关于这个问题的其他帖子还有其他因素比我的更令人讨厌).

从laravel.log(下面)没有任何东西跳出来 - 任何想法?

[2015-11-26 12:25:55] local.ERROR: exception 'Swift_TransportException' with message 'Failed to authenticate on SMTP server with username "dianekaplan@gmail.com" using 3 possible authenticators' in /home/vagrant/Code/Family-laravel/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php:181
Stack trace: …
Run Code Online (Sandbox Code Playgroud)

email swiftmailer laravel

17
推荐指数
4
解决办法
8万
查看次数