与Swift Mailer有问题不发送消息 [英] Got issue with Swift Mailer Not sending messages

查看:146
本文介绍了与Swift Mailer有问题不发送消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个swift邮件程序的问题,它不发送消息给用户我将库解压到我的网站的公司文件夹,并为swift邮件程序创建以下消息发送:

I have an issue with swift mailer, it is not sending message to the user I extracted the library to inc folder in my website and created the following message for swift mailer to send:

注意:如果您可以提出除SwiftMailer以外的其他解决方案,请您留言。

NOTE: If you can suggest other solutions besides SwiftMailer, could you please leave a comment.

require_once 'inc/lib/swift_required.php';

    //Create the Transport
    $transport = Swift_SmtpTransport::newInstance('mail.mywebsite.com', 25)
    ->setUsername('info@mywebsite.com')
    ->setPassword('myPassword')
    ;

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

    //Define Message Subject
    $message = Swift_Message::newInstance('myWebsite Registration')

    //e-mail from
    ->setFrom(array('info@mywebsite.com' => 'myWebsite'))
    //e-mail to
    ->setTo(array('$email1' => '$username'))
    //e-mail body
    ->setBody('

    Message body Here

    ')
    ;

    $result = $mailer->send($message);

    //Show user message after message has been sent
    include_once 'msgToUser.php'; 
    exit();

我测试过,我没有收到消息,我不明白为什么,我跟着官方指示: http://swiftmailer.org/docs/sending.html

I tested it and I didn't get a message and I don't understand why, I followed instructions at official website: http://swiftmailer.org/docs/sending.html

任何人都可以提出问题是什么?

Can anyone suggest what the problem is?

注意:我已经使用PHP mail(); 函数之前发送电子邮件,但被归类为垃圾邮件。如果可能,任何人都可以提出解决方案如何使用 mail(); 并使电子邮件不是垃圾邮件?请不要建议如下:使用您的主机服务器而不是您的域,例如而不是使用info@yourdomain.com使用info@yourhost.com。

NOTE: I have used PHP mail(); function before to send e-mails, but they were classified as spam. If possible can anyone suggest solution how to use mail(); and make e-mails not SPAM? Please don't suggest something like: use your host server instead of your domain, e.g. instead of using info@yourdomain.com use info@yourhost.com.

推荐答案

我担心你的问题可以没有具体的回答,因为在具体的技术问题下,你可以面对复杂的问题,需要多个地方被触动,这不是微不足道的。

I fear that your question can not be specifically answered, because next to concrete technical problems you can face complex problems here that need multiple places to be touched which is not trivial.

发送问题

首先,您可以使用SwitfMailer发送电子邮件,这应该只是工作 tm 。但是,如果您正在使用的传输(如SMTP服务器)不提供与SwiftMailer直接相关的电子邮件(因为它不会与PHP 邮件相关))。

First of all, you can send emails with SwitfMailer, this should "just work"tm. However, if the transport you're using, like the SMTP server is not delivering the emails, that is not related to SwiftMailer directly (as it wouldn't be related to PHP mail).

但是,您可以使用SwitfMailer的 $ result 来确定SwiftMailer本身是否正在运行发送电子邮件的任何错误。请参阅 SwiftMailer SMTP疑难解答(存档副本)获取更多信息,以防您有问题使SwiftMailer能够与您的SMTP服务器配合使用。

However, you can use the $result from SwitfMailer to find out if SwiftMailer itself was running into any errors sending the email. See SwiftMailer SMTP Troubleshooting (Archived Copy) for some more info in case you've got problems to get SwiftMailer to work with your SMTP server.

垃圾邮件问题

无法明确回答。类似的问题会随时出现在这里,但是大多数情况下,事情并没有得到明确的回答,因为这个主题延续了什么内容具有你的电子邮件(电子邮件标题和身体垃圾评分),从哪个服务器发送(IP地址和基于主机名的垃圾邮件评分,例如黑名单以及主机名的DNS配置,请参阅 SPF )和其他的东西。

This can not be specifically answered. Similar questions pop up here on SO from time to time, but most often things are not specifically answered because this topic stretches over what exact content has your email (email header and body Spam scoring), from which server it is send (IP-Address and Hostname based Spam scoring, e.g. blacklists as well as DNS configuration for the Hostname, see SPF) and other stuff.

使用SwiftMailer可以帮助您更换邮件后端,例如购买商业SMTP网关,专注于降低您的邮件的负担,作为垃圾邮件。但是,正如我在其他一些答案/评论中所写的那样:整个业务正在垃圾邮件上运行 - 在坏和好一方。所以不要信任任何这些实体。

Using SwiftMailer can help as you can exchange mailer backends, e.g. to buy-in a commercial SMTP gateway that focusses to lower the burden of your mails scored as Spam. However as I wrote it in some other answer/comment: A whole business is running on spam - on the "bad" and the "good" side. So it's not always advisable to trust any of these entities.

相反,您可以开始了解电子邮件技术如何运作,垃圾邮件评分工作方式以及您可以做什么通过正确配置的SMTP服务器发送正确的电子邮件。这是一些工作,它不能作为一个答案提供,因为它是非常广泛的。

Instead you can start to learn about how email technically works, how spam scoring is working and what you can do to send correct emails over a properly configured SMTP server. That is some work and it can not be provided as an answer here because it's very broad.

这篇关于与Swift Mailer有问题不发送消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆