Our SMTP servers require that you pass SMTP authentication before they will relay email from a php application. You can use the code below to define SMTP authentication.
| <html> |
| <head><title>Test email via php</title></head> |
| <body> |
| <? |
| require_once "Mail.php"; |
| $from = "Sender <postmaster@HostingAccountDomain.com>"; |
| $to = "Recipient <user@HostingAccountDomain.com>"; |
| $subject = "This is a test email sent via php"; |
| $body = "This is a test email"; |
| $host = "mail.HostingAccountDomain.com"; |
| $username = "postmaster@HostingAccountDomain.com"; |
| $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> |
If you run in to problems
using this code, please post in our community forum. Technical
support cannot assist with specific coding related issues.
Article ID: 826, Created On: 7/1/2010, Modified: 4/21/2011