"how to send email from php without smtp server installed?" Code Answer


yes, phpmailer is a very good choice.

for example, if you want, you can use the googles free smtp server (it's like sending from your gmail account.), or you can just skip the smtp part and send it as a typical mail() call, but with all the correct headers etc. it offers multipart e-mails, attachments.

pretty easy to setup too.


$mail = new phpmailer(true);

//send mail using gmail
    $mail->issmtp(); // telling the class to use smtp
    $mail->smtpauth = true; // enable smtp authentication
    $mail->smtpsecure = "ssl"; // sets the prefix to the servier
    $mail->host = "smtp.gmail.com"; // sets gmail as the smtp server
    $mail->port = 465; // set the smtp port for the gmail server
    $mail->username = "your-gmail-account@gmail.com"; // gmail username
    $mail->password = "your-gmail-password"; // gmail password

//typical mail data
$mail->addaddress($email, $name);
$mail->setfrom($email_from, $name_from);
$mail->subject = "my subject";
$mail->body = "mail contents";

    echo "success!";
} catch(exception $e){
    //something went bad
    echo "fail - " . $mail->errorinfo;

By David Betts on January 10 2022

Answers related to “how to send email from php without smtp server installed?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.