How to send email from a php script

Discussion in 'Email Discussions' started by popowich, Apr 25, 2014.

  1. popowich

    popowich EQ Forum Admin Staff Member

    Aug 12, 2008
    Likes Received:
    To send email from a php script use the following code that requires an email recipient, subject line, the message body, and what address the email should be sent From:

    $subject "The subject of the email"
    $body "This is an example email sent from a php script";
    $from "";

    if (
    mail($to$subject$body$from)) {   
    "<p>Success - Email sent"); 
    } else {     
    "<p>Fail - Error sending email");   
    To help prevent your email being marked as spam be sure to add a valid From: address so the email is not sent as your web server address.

Want to reply or ask your own question?

It only takes a minute to sign up (and it's free!). Click the orange sign up button to choose a username and then you can ask your own questions on the forum.