PHP SMTP send mail with SwiftMailer

PHP send mail with SwiftMailer Sample Code

Note: is your actual domain name. name is your actual email address name. your_email_password is your actual email password.

require_once 'swift_required.php';

// Create the Transport
$transport = Swift_SmtpTransport::newInstance('', 587)

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

// Create a message
$message = Swift_Message::newInstance('Message Using Swiftmailer')
->setFrom(array('' => 'From Name'))
->setTo(array('' => 'To Name'))
->setBody('Here is the message itself')

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

// Print to screen
print("Message Sent");


Add Feedback