Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8522359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:05:37+00:00 2026-06-11T07:05:37+00:00

I am using swift-mailer to send email to user. I have implemented it and

  • 0

I am using swift-mailer to send email to user. I have implemented it and it works well. But I have different body for different mails, ie i need to include the ID, Name , address in the mail which is taken from the database. I was thinking of using a loop for this. But many of article shows its not a good practice to send the mail in loop. I use this helpful tutorial as reference. Is there any better way for this, If loop is to be used how could i implement this. I dont have much experience in php, I am basically a jsp developer.

My CODE

<?php
require_once 'lib/swift_required.php';

// Create the Transport
$transport = Swift_SmtpTransport::newInstance('smtp.mysite.net', 25)

  ->setUsername('me@mysite.net')
  ->setPassword('me123456')
  ;

$transport = Swift_MailTransport::newInstance();

// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);

// Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('me@mysite.net' => 'My Name'))
->setTo(array('name1@mysite.net', 'name2@mysite.net'))
->setBody('Here is the message itself')
  ;

// Send the message
$result = $mailer->send($message);


?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:05:39+00:00Added an answer on June 11, 2026 at 7:05 am

    Sending email in a loop is not a good practice, because you could be treated as a spammer by your SMTP provider.
    You should have a look into Decorator plugin for Swift mailer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to send over 2000 mails and I am using Swift Mailer library
I am using PHP Swift Mailer to send Mail to my user, whose email
I am using swift mailer using this statement: require_once 'lib/swift_required.php'; to send email. It
I am using Swift Mailer to check for bounced messages. I have created one
I want to send out batch mails using SwiftMailer but just wondering what the
I am using PHP Swift Mailer to send a bulk mail to a set
I want to send out batch mails using SwiftMail or any similar system. The
I'm trying to send an email using swift_smtptransport that will connect to 127.0.0.1:25 I'm
Having big problems trying to get my php script to send email. Using this
I am creating a mail class in symfony using swiftmailer. I have written mailer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.