Emails can't be send Report this post Quote

Get help from other users here.

Moderators: Contributor, Developer

Post Reply
sachinkhanna48
Posts: 1
Joined: May 13, 2018 10:30 am

Emails can't be send Report this post Quote

Post by sachinkhanna48 » May 14, 2018 2:42 pm

Hello,

I looked the initial post with how to proceed but send emails doesn't works.
If I use a simple email sending script, it works but not with testmail.php

here the lines of code. Please, can you tell me how is bad here ?
Thank you

require_once "Mail.php";

$from = "myname@mydomain.com";
$to = "email@address.fr"; //CHANGE THIS TO YOUR GMAIL ADDRESS WELL
$subject = "TEST";
$body = "Hi,\n\nHow are you?";

$host = "secureamsss2.sgcpanel.com";
$port = "465";
$username = "myname@mydomain.com"; //CHANGE THIS TO YOUR GMAIL ADDRESS WELL
$password = "MYPASSword"; //CHANGE THIS TO YOUR GMAIL PASSWORD

$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
What's happen, something wrong ?
thank you :)

Post Reply