Emails can't be send

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
macchu
Posts: 11
Joined: 06 Jan 2017, 17:19

Emails can't be send

Post by macchu »

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

Code: Select all

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