Hi all. I've copied the suggested php email code from the support section of Winhost, however I still can't get it to work. Do you need to further specify the SMTP or is that already in the code? The 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.isgaust.net.au"; $username = <[email protected]>"; $password = "xxx"; $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>
Hi. If I publish it as HTML or ASPX it comes up as below $from, 'To' => $to, 'subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); ?> which tells me there is an error in the code but I can't find it for the life of me. If I publish it as .php, it says it cannot display the page.
The username/password doesn't have to reflect the postmaster account, does it? It can be any email account you've got set up?
So I've managed to reduce the faulty code to $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); ?> now by changing the code to this: <html> <head><title>Test email via php</title></head> <body> <?php require_once "Mail.php"; $from = "[email protected]"; $to = "[email protected]"; $subject = "This is a test email sent via php"; $body = "This is a test email"; $host = "mail.isgaust.net.au"; $username = "[email protected]"; $password = "testaccount"; $headers['From'] = "[email protected]"; $headers['To'] = "[email protected]"; $headers['subject'] = "email test"; $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); ?> </body> </html> So it looks like it didn't like the alternative way of casting the first array. Now I've got to work out how to re-write the second array so it works.
My problem starts out identical to that of Oliver Freeman, and I don't have the luxury of working through it as he did. Who can I hire to fix it?
Hi Joe, Don't use the variables in the $smtp = Mail:: line. Put the host, username and password directly in the line. This worked for me. $smtp = Mail::factory('smtp', array ('host' => 'mail.DOMAIN', 'auth' => true, 'username' => 'postmaster@DOMAIN', 'password' => 'XXXX')); Kind regards, Ferry