Orchestration of thoughts

Orchestration of thoughts

Maheshwaran Subramaniya  //  A computer science engineer and mac geek, who pour thoughts on technology, computer science, mathematics and other thoughtful stuffs.

I'm blogging at My Mind Leaks ( http://mymindleaks.com )

Apr 4 / 11:02pm

php mail() alternate to send mail in Webfaction

Webfaction doesnt support PHP mail(), for users who need to use mail functionality in their PHP application, they can try the SMTP way of mailing. To do this follow these steps

1. Get the PEAR Mail package

If your web provider supports SSH, you can try these commands

$ gzip -d <filename>
$ tar -xf <filename>.tar

2. Place the Mail.php file in a appropriate location in the server

3. Edit your mailing php script and place the below code.

$smtp = Mail::factory('smtp',
array ( 'host' => 'smtp.webfaction.com',
'auth' => true,
'username' => 'your_smtp_username',
'password' => 'your_smtp_password' 
)
);

4. Create headers to specify the format of the mail

$headers = array (
'Mime-Version' => '1.0',
'Content-Type' => 'text/html; charset="ISO-8859-1"',
'Content-Transfer-Encoding' => '7bit',
'From' => $from_name . "<" . $from_email . ">",
'To' => $to_email,
'Subject' => $subject
);

$mail = $smtp->send( $to_email, $headers, $html_content);

if ( $mail ) {
//success
 } else {
//failure
}