Sending E-mail on Apache Servers

For sites hosted on Apache servers, we support sending emails via PHPmailer.

For most users, slight modifications to the sample code below should be sufficient. However, for those who want more details on exactly how the emails are sent or for instances where you need to go beyond this simple example, take a look at the PHPmailer tutorial.

Important: Never create a form that gives the user control of both the FROM and TO addresses. This means that either FROM or TO must be hard-coded into your form script. This could allow someone to use the form for spamming, and is grounds for termination of your hosting account.

Sample Code:
From = "do-not-reply@4w.com";
$mail->FromName = "System administrator";
$mail->Host = "mail.infoanalytic.com";
$mail->Mailer = "SMTP";

// HTML body
$body = “Hello Customer,
“;
$body .= “You have mail.
“;
$body .= “Sincerely,
“;
$body .= “ABC Corp”;

// Plain text body (for mail clients that cannot read HTML)
$text_body = “Hello Customer, \n\n”;
$text_body .= “You have mail.\n\n”;
$text_body .= “Sincerely, \n”;
$text_body .= “ABC Corp”;

$mail->Body = $body;
$mail->altBody = $text_body;
$mail->addAddress(“jane@somedomain.com”, “Jane Johnson”);

if(!$mail->Send())
echo “The following error occured: ” . $mail->ErrorInfo;
else
echo “Your email has been sent”;
?>