I am using this very tiny piece code to test whether an email reaches the email destination:
<?php
mail('woodsy013@hotmail.com','Test mail','The mail function is working!');
echo 'Mail sent!';
?>
But it doesnt seem to be working. I am using WAMP. I have installed a free SMTP server. And my php.ini file is configured to the following:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.tools.sky.com
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = you@yourdomain
I dont seem to be receiving an email to woodsy130@hotmail.com following the actions I have mentioned.
I get this error:
Warning: mail() [function.mail]: SMTP server response: 530 5.7.0
Must issue a STARTTLS command first. ff2sm10904265wib.9 in
C:\wamp\www\Derrysgc2\pages\pages\mailtest.php on line 2
Any suggestions?
Try using SMTP server with gmail.
ini_set("SMTP","ssl://smtp.gmail.com");
ini_set("smtp_port","465");
or else there are many PHP mailer library. which simplifies things for you and makes it so easier to use. my fav is swift mailer. the best part about is you don't have to mess with your core php configuration file and the documentation too is very easy to read.
for example if you want to send a mail using PHP's swift mailer library it is as simple as.
require_once 'lib/swift_required.php';
// Create the Transport
$transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25)
->setUsername('your username')
->setPassword('your password');
// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
// Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('john@doe.com' => 'John Doe'))
->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name'))
->setBody('Here is the message itself');
// Send the message
$result = $mailer->send($message);
you can refer the documentation for more information on the official website http://swiftmailer.org/docs
Shouldn't SMTP point to your SMTP server? (I am assuming smtp.tools.sky.com is your provider). Also sendmail_from should be a correct emailaddress.
Also note some mail provders block email sent from dynamic ip adresses.