note 82433 deleted from ref.mail by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 20:02:16 +0000 |
| Subject: | note 82433 deleted from ref.mail by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155314@lists.php.net to get a copy of this message | ||
Note Submitter: contact at xpertmailer dot com
----
In reply to anschwartz. If you don't want to install a mail server you can use a free external
SMTP mail server to send your mails (like Gmail) with a free PHP Class (like XPertMailer, Zend
Framework Mail, PHPMailer or PEAR Mail). Send mail using Gmail and XPertMailer v.4
(http://www.xpertmailer.com/) :
<?php
// path to 'MAIL.php' file from XPM4 package
require_once '/path-to/MAIL.php';
$m = new MAIL; // initialize MAIL class
$m->From('username@gmail.com'); // set From mail address
$m->AddTo('client@destination.net'); // add To mail address
$m->Subject('Hello World!'); // set your mail subject
// set your mail message (text/html)
$m->Html('<b>HTML</b> <u>message</u>.');
// connect to MTA server 'smtp.gmail.com' port '465' via SSL ('tls'
encryption)
// with authentication: 'username@gmail.com' and 'password'
// set the connection timeout to 10 seconds, the name of your
// host 'localhost' and the authentication method to 'plain'
// make sure you have OpenSSL module (extension) enable on your php configuration
$c = $m->Connect('smtp.gmail.com', 465, 'username@gmail.com',
'password',
'tls', 10, 'localhost', null, 'plain') or die(print_r($m->Result));
// send mail relay using the '$c' resource connection
echo $m->Send($c) ? 'Mail sent !' : 'Error !';
// disconnect from server
$m->Disconnect();
?>