标签: swiftmailer

使用Swiftmailer的多个附件

我正在创建一个允许上传多个文件的表单.然后将表单字段值和附件通过电子邮件发送到特定地址.我正在使用Swiftmailer生成这些电子邮件.我知道如何使用Swiftmailer附加文件,但我不知道如何附加多个文件.有人知道使用Swiftmailer是否可行吗?

php email swiftmailer

12
推荐指数
1
解决办法
8119
查看次数

如何在Symfony中添加附件到电子邮件?

我想在电子邮件中添加附件.我正在使用sfmailer类.

我在下面给出了我的代码:

$mail_body = '<p>custom html mail content</p>';
$message = Swift_Message::newInstance('Message title')
  ->setFrom(array('sender'))
  ->setTo(array('receiver'))
  ->setBody($mail_body, 'text/html', 'utf-8');

try {
  $this->getMailer()->send($message);
}
catch(Exception $e) {

}
Run Code Online (Sandbox Code Playgroud)

php email symfony1 swiftmailer symfony-1.4

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

SwiftMailer错误未定义属性:Swift_Transport_StreamBuffer :: $ _ sequence

我正在使用SwiftMailer通过SMTP发送电子邮件.在PHP版本5.4的服务器上运行时,该库工作正常.但是,在将服务器升级到PHP 5.5之后,未发送电子邮件,服务器发出以下错误:

Undefined property: Swift_Transport_StreamBuffer::$_sequence
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?谢谢.

php swiftmailer php-5.5

12
推荐指数
2
解决办法
7531
查看次数

PHP - 使用STARTTLS和自签名证书的Swiftmailer

我正在尝试使用STARTTLS发送带有php和swiftmailer的电子邮件,但我收到了证书错误.我具有SMTP服务器的root访问权限,并且使用的证书是自签名的.我在两台机器上使用Debian(Web服务器和smtp服务器)

PHP message: PHP Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in [..]/lib/classes/Swift/Transport/StreamBuffer.php on line 97 PHP message: PHP Fatal error: Uncaught exception 'Swift_TransportException' with message 'Unable to connect with TLS encryption' in [..]/lib/classes/Swift/Transport/EsmtpTransport.php:294

我是否需要在某个地方添加自己的证书才能接受它?或者这是一些OpenSSL配置错误?

php smtp certificate self-signed swiftmailer

12
推荐指数
3
解决办法
2万
查看次数

尝试调用类"Swift_Message"的名为"newInstance"的未定义方法

几天后我不再使用Symfony和Swiftmailer发送电子邮件了,虽然我正在使用文档中的代码

private function _sendResetPasswordEmail(UserInterface $user)
{   
    $subject = $this->get('translator')->trans('email-title-reset-password');
    $message = \Swift_Message::newInstance()
        ->setSubject($subject)
        ->setFrom('contact@example.com')
        ->setTo($user->getEmail())
        ->setBody(
            $this->renderView(
                'reset-password-email.html.twig',
                ['user' => $user]
            ),
            'text/html'
        )
    ;
    $this->get('mailer')->send($message);
}   
Run Code Online (Sandbox Code Playgroud)

它曾经工作过

现在我可以在日志中看到

"Attempted to call an undefined method named "newInstance" of class "Swift_Message"
Run Code Online (Sandbox Code Playgroud)

什么可以改变?

swiftmailer symfony

12
推荐指数
1
解决办法
2337
查看次数

PHP库读取电子邮件

我目前使用SwiftMailer库发送电子邮件,但遗憾的是它仅用于发送,而不是接收.我想知道...是否有类似的库通过IMAP连接到电子邮件帐户并阅读电子邮件(IE让我能够循环通过电子邮件).我知道这里有一组PHP IMAP函数:http://us3.php.net/manual/en/book.imap.php

但我的问题是,是否有人知道用于接收/查看所有电子邮件的替代图书馆或IMAP包装类?

事先谢谢,我真的找不到任何东西.

php email imap email-client swiftmailer

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

Silex SwiftMailer在执行时不进行SMTP连接

我正在制作一个使用SwiftMail扩展程序发送的控制台应用程序.由于我们的策略,我有两个虚拟机,一个用作SMTP中继,另一个用作应用服务器.通过telnet手动发送邮件到继电器工作正常.使用SwiftMail时,它已经坏了.

返回标头,$failure变量中没有返回任何条目send()

回应 getHeaders()->toString()

Message-ID: <1351104631.508838778dc03@swift.generated>
Date: Wed, 24 Oct 2012 14:50:31 -0400
Subject: [YourSite] Feedback
From: noreply@localhost.com
To: sixeightzero@localhost.com
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Run Code Online (Sandbox Code Playgroud)

如果我回应send(),我得到1.

boot.php

$app->register(new Silex\Provider\SwiftmailerServiceProvider(), array(
    'swiftmailer.options' => array(
        'host' => 'ip.host.relay',
        'port' => 25,
        'encryption' => null,
        'auth_mode' => null
    ),
));
Run Code Online (Sandbox Code Playgroud)

app.php

 $message = \Swift_Message::newInstance( )
        ->setSubject('[YourSite] Feedback')
        ->setFrom(array('noreply@localhost.com'))
        ->setTo(array('sixeightzero@localhost.com'))
        ->setBody("Message!");


    $app['mailer']->send($message, $failures);
Run Code Online (Sandbox Code Playgroud)

当我在应用服务器上运行TCP转储并运行脚本时,没有建立任何SMTP连接,并且没有抛出任何错误.

有没有遇到过这个?由于我们的应用程序要求,我不想使用sendmail或邮件,而是使用SMTP.

php swiftmailer silex

11
推荐指数
1
解决办法
3604
查看次数

将内嵌图像添加到使用swiftmailer发送的消息中

请原谅我的PHP但是,我使用Swiftmailer从客户网站发送电子邮件.他们要求添加一个或两个图像作为签名等,所以在这里查看swiftmailer规范

http://swiftmailer.org/docs/messages.html

他们建议添加这样的内嵌图像

$message->embed(Swift_Image::fromPath('http://site.tld/image here'))
Run Code Online (Sandbox Code Playgroud)

或者像这样(分2步)

$cid = $message->embed(Swift_Image::fromPath('image here'));
Run Code Online (Sandbox Code Playgroud)

然后在电子邮件正文部分添加

<img src="' . $cid . '" alt="Image" />'
Run Code Online (Sandbox Code Playgroud)

我试过这两个步骤但无济于事.当我点击发送电子邮件按钮,我得到这个错误,我不知道该怎么做.

Call to a member function embed() on a non-object in /home/content/78/5152878/html/4testing/erase/ask-doc-proc2.php on line 89
Run Code Online (Sandbox Code Playgroud)

我添加到我已经工作的代码和电子邮件中的唯一内容是直接来自文档页面中示例的图像代码.此错误显然会阻止发送电子邮件.如果我删除它然后它发送电子邮件很好.因为我需要为此添加图像,

任何帮助是极大的赞赏.谢谢

编辑:这是构建电子邮件的部分并发送 $ cid = $ message-> embed(Swift_EmbeddedFile :: fromPath(' http://myforecyte.com/dev/pic.jpg '));

->setTo( $docEmail)

->setBody("Hello" . "\r\n\r\n" .  
$fullName . " has visited MyForeCYTE.com. Upon their visit they have requested to learn more about the test. \r\n\r\n" . 
"Please visit www.ClarityWomensHealth.com to find out more …
Run Code Online (Sandbox Code Playgroud)

php swiftmailer

11
推荐指数
3
解决办法
2万
查看次数

在每个环境中禁用Symfony中的swiftmailer spool

我无法通过console命令使用symfony2发送批量电子邮件.我想为运行控制台的env禁用邮件假脱机完成,但保持其工作为默认环境.所以我在config.yml中有这个:

swiftmailer:
    transport: %mailer_transport%
    host:      %mailer_host%
    port:      %mailer_port%
    username:  %mailer_user%
    password:  %mailer_password%
    spool:     %mailer_spool_type%
Run Code Online (Sandbox Code Playgroud)

然后每个env都有参数,如parameters_prod.yml:

parameters:
    mailer_transport:       smtp
    mailer_host:            smtp.someserver.net
    mailer_port:            587
    mailer_user:            "someuser"
    mailer_password:        "somepassword"
    mailer_spool_type:      { type:memory }
Run Code Online (Sandbox Code Playgroud)

然后对于控制台env我使用parameters_cron.yml:

parameters:    
    mailer_spool_type: ~
Run Code Online (Sandbox Code Playgroud)

问题是使用~null实际上没有关闭假脱机但它使用默认值{cache: file, path: %kernel.cache_dir%/swiftmailer/spool }

有没有办法通过更改参数来禁用线轴或有更好的方法吗?

php yaml swiftmailer symfony

11
推荐指数
1
解决办法
8104
查看次数

Swiftmailer - 未捕获错误:调用未定义的方法Swift_SmtpTransport :: newInstance()

我正在尝试使用Swiftmailer.发送电子邮件.

我得到一个未捕获的错误:

调用未定义的方法Swift_SmtpTransport :: newInstance().

这是代码:

require_once 'swift/lib/swift_required.php';

$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
      ->setUsername ('email@gmail.com')
      ->setPassword ('password');

$mailer = Swift_Mailer::newInstance($transport);

$message = Swift_Message::newInstance('Weekly Hours')
       ->setFrom (array('email@gmail.com' => 'My Name'))
       ->setTo (array('email@hotmail.com' => 'Recipient'))
       ->setSubject ('Weekly Hours')
       ->setBody ('Test Message', 'text/html');

$result = $mailer->send($message);
Run Code Online (Sandbox Code Playgroud)

根据上面的代码,会导致这个错误的原因是什么?

php swiftmailer php-7

11
推荐指数
1
解决办法
7266
查看次数