How do I send email using PHP with ASPemail

Expand / Collapse
 
     

How do I send email using PHP with ASPemail


NOTE: This article is for Window Hosting Only.  For Linux Hosting, please refer to here.

You need to:
1. use your email server as the smtp, this is usually mail.yourdomain.com
2. authenticate to the smtp server
3. make sure your "From" address is exactly the same as your login address in NetworkCredential class


Sample php code using aspemail COM+. (aspemail COM+ is supported by our hosting)

<?php
$mailer = new COM("Persits.MailSender")  or die("Unable to instantiate aspemail");
echo $mailer->version;
$smtp = "mail.sender.com";
$from = "
info@sender.com";
$login = "info@sender.com";
$pwd = "password";
$to = "tom@recipient.com";
$subject = "Subject";
$body = "This is message body";

$mailer->Host = $smtp;
$mailer->Username = $login;
$mailer->Password = $pwd;
$mailer->From = $from; // From address
$mailer->AddAddress($to);

$mailer->Subject = $subject;
$mailer->Body = $body;

$mailer->Send() or die("failed");
unset($mailer);
?>

 

If the above sample code does not work you can try the pure php variant from http://phpmailer.sourceforge.net/. Sample code can be found here.


Tags:




Add Your Comments


Name: *
Email Address:
Web Address:
Verification Code:
*
 

Details
Last Modified:5/19/2009 5:51 PM
Last Modified By: Mark
Type: How to do this?
Rated 5 stars based on 1 vote.
Article has been viewed 2,217 times.
Options