swiftmailer

“Connection could not be established with host smtp.gmail.com”. Symfony. Swiftmailer

我是研究僧i 提交于 2019-12-13 07:01:58
问题 I got exception: Connection could not be established with host smtp.gmail.com Same exception in old project Symfony2.8 and newest Symfony3. I can ping smtp.gmail.com . 回答1: The Avast Antivirus was guilty. 回答2: In Google "Account settings" enable "Access for less secured apps" by setting it to "Allow". Mailer host is your localhost or 127.0.0.1. It's not smtp.google.com 回答3: I'm using this configuration for my localhost application parameters: mailer_transport: gmail mailer_host: smtp.gmail

How to make SUBJECT Substitutions in Sendgrid Swift SmtpTransport?

非 Y 不嫁゛ 提交于 2019-12-13 04:39:53
问题 I am using Swift SmtpTransport as it seems to be the recommended way. However the documentation I found dos not show how to achieve Subject Substitutions. (This is what I am using) https://github.com/sendgrid/sendgrid-php-example/blob/master/smtp-php-example.php https://github.com/sendgrid/sendgrid-php http://swiftmailer.org/docs/sending.html#quick-reference-for-sending-a-message 回答1: This was answered on Github, answering here too, for folks future reference. To use the SMTPAPI to substitute

Swiftmailer: sending email to multiple recipient

感情迁移 提交于 2019-12-13 03:42:06
问题 I am trying to send email from a contact form through swiftmailer lib. My setup sends mail to a single recipient, but when I try sending to more than one email, it throws an error: Address in mailbox given [email1@gmail.com,email2@gmail.com] does not comply with RFC 2822, 3.6.2. but the two emails are valid according to the specification. Here is the code; $failed = []; $sent = 0; $to = []; if (isset($_POST['recipients'])) { $recipients = $_POST['recipients']; } // Send the message foreach (

Avoiding Spam Filters for account confirmation emails

你。 提交于 2019-12-13 00:50:04
问题 I have an application built in PHP/Symfony. Part of it requires sending what is essentially an account verification email to users. Unfortunately, it seems that my email is triggering spam filters (gmail, hotmail, probably others) and not making it to the users inboxes. What strategies can I use to avoid being filtered? 回答1: Rather than sending mail from the server where your website runs, it's better to use trusted external mail server. You can do that with Swift_SmtpTransport. You can even

send mails via sendgrid

喜欢而已 提交于 2019-12-12 18:41:14
问题 I'm trying to send mails via sendgrid, here my code : // 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,

LogicException: Missing default data in Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector

泪湿孤枕 提交于 2019-12-12 12:25:29
问题 Getting this exception in Symfony 2.5.5 with Swiftmailer 5.3.0. I'm following the cookbook example exactly. The error is thrown when calling MessageDataCollector#getMessages() : // Check that an e-mail was sent $this->assertEquals(1, $mailCollector->getMessageCount()); $collectedMessages = $mailCollector->getMessages(); $message = $collectedMessages[0]; The message count assertion is also failing with a value of zero. As far as I can tell the collector is failing to do any actual collecting

Does Gmail not allow sender to set a return path value to receive bounce messages?

£可爱£侵袭症+ 提交于 2019-12-12 12:23:38
问题 I am using Swift Mailer to check for bounced messages. I have created one separate account for bounce messages, however when I set the return path, it does not allow the bounce message send to that account. Is it normal or is it a code error? $verp = 'bounces-' . str_replace('@', '=', $row['ReplyTo']) . '@gmail.com'; $message = Swift_Message::newInstance() ->setSubject($row['Subject']) ->setFrom(array($row['ReplyTo'] => $row['FromName'])) ->setReturnPath($verp) ->setBody($html, 'text/html') -

Google App-Gmail Unable to set from. Gmail replacing from address when sending via swiftmailer SMTP transport (PHP)

风格不统一 提交于 2019-12-12 11:56:46
问题 Hello and thank you for any help in advance. I'm using swiftmailer, SMTP transport method to send email from my PHP script. Sending the message is fine. It works. The problem is, no matter what I set the FROM,REPLYTO,SENDER settings to, The email comes through as the GMAIL mailbox (ME - me@mydomain.com) instead. $transport = Swift_SmtpTransport::newInstance('imap.gmail.com', 465,'ssl') ->setUsername($login) ->setPassword($password) ; $message = Swift_Message::newInstance($subject) ->setFrom

Sending email using php, gmail, and swiftmailer causes SSL-related error

落花浮王杯 提交于 2019-12-12 09:35:59
问题 Here is my PHP code: function SendCookieToTheMail() { require_once 'swift-mailer/lib/swift_required.php'; //Create the Transport $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com') ->setPort(465) ->setEncryption('ssl') ->setUsername('007@gmail.com') ->setPassword('123') ; //Create the Mailer using your created Transport $mailer = Swift_Mailer::newInstance($transport); //Create a message $message = Swift_Message::newInstance('Test') ->setFrom(array('007@gmail.com' => 'From mr. 007'

swiftmailer Swift_TransportException gets uncaught by try-catch block

走远了吗. 提交于 2019-12-12 08:12:45
问题 For a project (which is about estate properties) i have included a contact form where a visitor can contact an estate broker if the visitor is interested to buy/hire an estate property. I am using Symfony2 and its library. For the contact mail, i am using the Swiftmailer library. Well, i have the next code which handles the form submit. there, I create a mail object to be able to send mails. It works, but i want to provide a error resolving service if there are problems with the smtp host