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

  • Home
  • SEARCH
  • 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 692545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:39:43+00:00 2026-05-14T02:39:43+00:00

i have downloaded Swift Mailer from their website and try to send simple email

  • 0

i have downloaded Swift Mailer from their website and try to send simple email with following code

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

    $transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25)
    ->setUsername('your username')
     ->setPassword('your password')
      ;


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

  //Create a message
  $message = Swift_Message::newInstance('Wonderful Subject')
  ->setFrom(array('john@doe.com' => 'John Doe'))
 ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name'))
 ->setBody('Here is the message itself')
 ;

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

?>

once i run the page it gives error

      Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: No such host is known. in E:\web_sites\swift_mail\lib\classes\Swift\Transport\StreamBuffer.php  on line 233

    Warning: fsockopen() [function.fsockopen]: unable to connect to smtp.anyhost.com:25 (php_network_getaddresses: getaddrinfo failed: No such host is known. ) in E:\web_sites\swift_mail\lib\classes\Swift\Transport\StreamBuffer.php on line 233

   Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp.domain.com [php_network_getaddresses: getaddrinfo failed: No such host is known. #0]' in E:\web_sites\swift_mail\lib\classes\Swift\Transport\StreamBuffer.php:235 Stack trace: #0 E:\web_sites\swift_mail\lib\classes\Swift\Transport\StreamBuffer.php(70): Swift_Transport_StreamBuffer->_establishSocketConnection() #1 E:\web_sites\swift_mail\lib\classes\Swift\Transport\AbstractSmtpTransport.php(101): Swift_Transport_StreamBuffer->initialize(Array) #2 E:\web_sites\swift_mail\lib\classes\Swift\Mailer.php(74): Swift_Transport_AbstractSmtpTransport->start() #3 E:\web_sites\swift_mail\test.php(33): Swift_Mailer->send(Object(Swift_Message)) #4 {main} thrown in E:\web_sites\swift_mail\lib\classes\Swift\Transport\StreamBuffer.php on line 235

if i remove the line

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

then page execute and no error message display, as soon as i add above line to send email, i got error.

my outgoing server, port and user id & passwords are correct in my file.

Thanks

  • 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-05-14T02:39:43+00:00Added an answer on May 14, 2026 at 2:39 am

    It’s looking for the server smtp.domain.org but isn’t able to resolve it.

    If you look at the line the last step in the stack trade is calling, you can see it throwing an exception:

    if (!$this->_stream = fsockopen($host, $this->_params['port'], $errno, $errstr, $timeout))
    {
      throw new Swift_TransportException(
        'Connection could not be established with host ' . $this->_params['host'] .
        ' [' . $errstr . ' #' . $errno . ']'
        );
    }
    

    So you either need to input a valid smtp server or wrap the send() line in a try/catch to catch the exception and either log it somewhere or ignore it

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

Sidebar

Related Questions

I have downloaded a web project from CodePlex and am getting the following error
I have downloaded a dynamic library from the location: http://downloads.php.net/pierre/ . The specific file
I have downloaded and added this very simple, one file, php web file explorer
I have downloaded a MetaTrader MQL4 language .mq4 source-code file from here and I
I have downloaded demo for Kal calendar from source code API at github and
I have downloaded a project from a website. But I don‘t want to import
I have downloaded the silver light from this http://www.microsoft.com/silverlight// I need to use this
I have downloaded Skype4COM from Skype so my question is, can i integrate it
Problem: Blank email from PHP web application. Confirmed: App works in Linux, has various
I have downloaded a WSDL file from Internet and just want to know how

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.