我使用 Symfony 1.4.8 和 Propel 作为 ORL。我正在使用 Symfony miler 对象发送邮件,邮件发送正确,但它进入垃圾邮件文件夹,有什么办法可以阻止它。我正在使用的代码,
$to_email_array=array("one@gmail.com","two@gmail.com");
$body="welcome to symfony";
$subject="from Symfony";
$from=array('me@mydomain.com' => 'our Domain');
$mail_object=$this->getMailer();
$message=Swift_Message::newInstance()
->setSubject($subject)
->setBody("<html> <head> </head> <body> <span>Dear {receiver}, </span>".$body."</body> </html>", "text/html")
->setFrom($from)
->setTo($to_email_array);
$mailed=$mail_object->batchSend($message);
Run Code Online (Sandbox Code Playgroud)
上面的代码是从一个 Symfony 任务调用的,我们使用我们自己的网络服务器发送邮件,使用我们的域名。邮件已发送,但进入垃圾邮件文件夹。有什么办法可以阻止邮件进入垃圾邮件文件夹。
我有一个通讯脚本,它循环通过成员并发送邮件给每个人.这之前运行正常,但随着数字的增加,脚本开始崩溃.我正在使用SwiftMailer,我得到的消息是"使用mail()作为PHP的默认邮件()发送失败".尝试使用SMTP而不是本机mail()函数发送会有什么好处吗?或者我应该看另一个解决方案.谢谢你的任何指示.
我在这里看到了Swiftmailer处理退回邮件的建议,但我在文档中看不到对此的支持.我错过了什么吗?在我看来,PHPMailer-BHM是唯一可以随时使用此功能的选项.如果这不正确,请详细说明.
我问,因为Swiftmailer看起来有最好的文档和支持向前发展,但我不想花时间重新发明轮子创建一个类来解析和处理NDR.
我正在尝试通过sendgrid发送邮件,这里是我的代码:
// Setup Swift mailer parameters
$transport = Swift_SmtpTransport::newInstance('smtp.sendgrid.net', 25);
$transport->setUsername($username);
$transport->setPassword($password);
$swift = Swift_Mailer::newInstance($transport);
// Create a message (subject)
$message = new Swift_Message($subject);
// attach the body of the email
$message->setFrom($from);
$message->setBody($html, 'text/html');
$message->setTo($to);
$message->addPart($text, 'text/plain');
// send message
if ($recipients = $swift->send($message, $failures))
{
// This will let us know how many users received this message
echo 'Message sent out to '.$recipients.' users';exit;
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:Swift_TransportException
预期的响应代码250,但得到代码"",带有消息""
...\swiftMailer\LIB \类\雨燕\传输\ AbstractSmtpTransport.php(422)
请帮我 !
我为客户开发了一个页面,我必须做一个时事通讯.我已经有了邮件的模板,我想要的是在这些电子邮件中插入图片.
代码 :
foreach($customer as $customer)
{
$mail = $customer->getMailcustomer();
$message = \Swift_Message::newInstance();
$message->setSubject('Info');
$message->setFrom('abcd@noreply.ch');
$message->setTo($mail);
$message->setContentType("text/html");
$message->setBody(
$this->renderView(
'MyBundle:Customer:email.html.twig',
array('form' => $form->createView())
)
);
$this->get('mailer')->send($message);
}
Run Code Online (Sandbox Code Playgroud)
此代码有效,我有一个很好的电子邮件页面,但我不知道如何在其中插入图片.
我试图插入一张图片,email.html.twig但它没有用.
我收到以下错误:
没有收件人,无法发送邮件
这是在尝试使用swiftmailer发送电子邮件时.我的代码在localhost中工作,并且具有从发送方到接收方所需的所有参数,但是它会抛出错误,说它无法在没有收件人的情况下发送.
这是我的代码:
public function email()
{
Mail::send('emails.auth.mail', array('token'=>'SAMPLE'), function($message){
$message = Swift_Message::newInstance();
$email = $_POST['email']; $name = $_POST['name']; $subject = $_POST['subject']; $msg = $_POST['msg'];
$message = Swift_Message::newInstance()
->setFrom(array($email => $name))
->setTo(array('name@gmail.com' => 'Name'))
->setSubject($subject)
->setBody($msg);
$transport = Swift_MailTransport::newInstance('smtp.gmail.com', 465, 'ssl');
//$transport->setLocalDomain('[127.0.0.1]');
$mailer = Swift_Mailer::newInstance($transport);
//Send the message
$result = $mailer->send($message);
if($result){
var_dump('worked');
}else{
var_dump('Did not send mail');
}
}
Run Code Online (Sandbox Code Playgroud)
}
我有一个1and1帐户,即时尝试使用symfony2.3和swift_mailer发送电子邮件,但这是不可能的.
我没有任何错误,我已经检查了symfony日志,但没有.
这是我的实现(在一个Action中):
$message = \Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('test@domain.com')
->setTo('myuser@mydomain.com')
->addCc('other@mydomain.com')
->setBody( "test body" )
;
$mailer = $this->get('mailer');
$result = $mailer->send($message, $fails);
//$fails receive a empty array
//$result get value 1
Run Code Online (Sandbox Code Playgroud)
这是配置:
swiftmailer:
transport: smtp #i also try mail and sendmail
host: smtp.1and1.mx #i also try smtp.1and1.es, auth.smtp.1and1.fr
username: someone@mydomain.net #the complete email someone@mydomain.net(this account is active, i'm able to login in webmail...)
password: mypass
spool: { type: memory }
encryption: tls # i also try without this setting …Run Code Online (Sandbox Code Playgroud) 我正在构建一个通过swiftmailer扩展程序发送电子邮件的Yii2应用程序.我将电子邮件设置(smtp,ssl,username等)存储在数据库表中,以便能够使用适当的视图对其进行编辑.如何从db表中使用config启动swiftmailer?
谢谢.
Gmail 文档说我需要create a MIME email messages compliant with RFC 2822. - https://developers.google.com/gmail/api/guides/sending
鉴于我只有一个“收件人”地址、主题和纯文本正文 - 是使用 SwiftMailer(或替代包)实现这一目标的最简单方法吗?
如果是这样,我如何确保 SwiftMailer 的输出适合 Gmail REST API?
我将使用此函数对它进行 Base64URL 编码:
function base64url_encode($data) {
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
Run Code Online (Sandbox Code Playgroud) 我无法连接 Gmail SMTP 服务器。
看:
$transport = Swift_SmtpTransport::newInstance()
->setHost('smtp.gmail.com')
->setPort(465)
->setEncryption('ssl')
->setUsername('email@gmail.com')
->setPassword('mypasss');
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance('Contato via Site')
->setFrom(array($email => $de))
->setTo(array($destinatario => 'Agência Linka'))
->setBody($corpo_mensagem, 'text/html')
->setCharset('UTF-8');
$mailer->send($message);
Run Code Online (Sandbox Code Playgroud)
然后我得到了这个:
Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp.gmail.com [ #0]' in ...
Run Code Online (Sandbox Code Playgroud)
任何人都经历过这种情况?