I am trying to use swiftmailer in my project so that I can send html newsletter to multiple users. I have searched thoroughly but all i got never worked for me. I want to paste more than one recipient in the form input field seperated by comma and send the html email to them.
I set the recipients to a variable($recipients_emails)
and pass it to setTo() method in the sending code, same with the html_email
.
Questions are: Q1 How do i send to more than one recipient from the recipient input field.
I tried this:
if (isset($_POST['recipients_emails'])) {
$recipients_emails = array($_POST['recipients_emails'] );
$recipients_emails= implode(',',$recipients_emails);
}
Q2 How do I make the Html within heredoc tag. when i tried concatenating like this ->setBody('<<<EOT'.$html_email.'EOT;', 'text/html');
, my message would appears with the heredoc tag.
if (isset($_POST['html_email'])) {
$html_email = $_POST['html_email'];
}
How do I have input from $_POST['html_email'];
to be within EOT tag;
this in part of swiftmailer sending script ;
$message = Swift_Message::newInstance()
->setSubject($subject)
->setFrom($from)
->setTo($recipients_emails)
->setBody($html_email, 'text/html');
Nota bene : Am still learning these things.
After creating your Gmail draft and your spreadsheet, select Extensions > Yet Another Mail Merge: Mail Merge for Gmail > Start Mail Merge. Then select the draft you created in your Gmail account next to Email Template and click Send emails. Each recipient receives an email with personalized content.
Open a new email and write the message you intend to send to your contact list. Click BCC in the top-right of your Compose window. Add all the email addresses to which you intend to send the message. It might help to copy and paste your list into this field.
Add multiple Cc recipients or Bcc recipients It's the same! You can add multiple Cc and Bcc by separating them with comma. Add the recipients in a column called "cc" for Cc recipients and "bcc" for Bcc recipients. To add multiple recipients, Cc or Bcc, just separate them with comma.
By default, a single SMTP transport creates a single connection and re-uses it for the lifetime of the script execution. You may send multiple e-mails through this SMTP connection.
According to this document
// Using setTo() to set all recipients in one go
$message->setTo([
'[email protected]',
'[email protected]' => 'Person 2 Name',
'[email protected]',
'[email protected]',
'[email protected]' => 'Person 5 Name'
]);
You can input array directly into setTo, setCc or setBcc function, do not need to convert it into string
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With