Hi, the following is the code I used to send email from my php file using SMPT with winhost. After running this php file, there is no error message but I did not get email in the destination mail box. I downloaded phpmailer and uploaded to the server. Can someone please check what is the problem. Many thanks. I hid up my password in the following code. <html> <head><title>Test email via php</title></head> <body> <?php require_once "phpmailer/phpmailerautoload.php"; $from = "Sender <[email protected]>"; $to = "Recipient <[email protected]>"; $subject = "This is a test email sent via php"; $body = "This is a test email"; $host = "mail.canadasmallbusiness.org"; $username = "postmaster"; $password = "********"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); ?> </body> </html>
still does not work. <html> <head><title>Test email via php</title></head> <body> <?php require_once "phpmailer/phpmailerautoload.php"; $from = "Sender <[email protected]>"; $to = "Recipient <[email protected]>"; $subject = "This is a test email sent via php"; $body = "This is a test email"; $host = "mail.canadasmallbusiness.org"; $username = "[email protected]"; $password = "*******"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); ?> </body> </html>
I helped you via chat and I used my own test code: <html> <head><title>Test email via php</title></head> <body> <?php require_once "Mail.php"; $from = "Sender <[email protected]>"; $to = "Recipient <[email protected]>"; $subject = "This is a test email sent via php"; $body = "This is a test email"; $host = "mail.HostingAccountDomain.com"; $username = "[email protected]"; $password = "email_password"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); ?> </body> </html> Our test code works above.