I am learning to use swift mail to send mail. I tried below code to send mail even the php success but didn't send any mail to my hotmail. I tried using 465 and 587 but both not sending mail to my hotmail.
<?php
require_once 'lib/swift_required.php';
echo 'Mail sent <br />';
$username = 'vic.ho******@gmail.com';
$password = 'password';
$transporter = Swift_SmtpTransport::newInstance('smtp.gmail.com', 587, 'ssl')
->setUsername($username)
->setPassword($password);
$mailer = Swift_Mailer::newInstance($transporter);
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('vic.ho******@gmail.com'))
->setTo(array('dark*****@hotmail.com'))
->setBody('Test Message Body')
;
$result = $mailer->send($message);
echo $result;
?>
before this i tried use the code below but come out error "Parse error: syntax error, unexpected ''vic.ho**@gmail.com'' (T_CONSTANT_ENCAPSED_STRING), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in C:\Users\Popo\Desktop\xampp\xampp\htdocs\test\mailtry.php on line 13"
this is the code
<?php
require_once 'lib/swift_required.php';
$transporter = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465,'ssl')
->setUsername($this-> 'vic.ho******@gmail.com')
->setPassword($this-> 'password');
$mailer = Swift_Mailer::newInstance($transporter);
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('vic.hon******@gmail.com'))
->setTo(array('dark******@hotmail.com'))
->setBody('Test Message Body')
;
$result = $mailer->send($message);
echo $result;
echo 'line 58 <br />';
?>
should i enable any configuration in the php.ini or mercury for sending mail?Or is due to firewall in my school so i cannot send mail? Because now i'm using XAMPP to sending mail. Hope someone can teach me or tell me other alternative ways to send mail. thanks!