PHP sending an HTML EMAIL Page from a website -
i've used php send emails before never send full html page source , i'm wondering start , few other things.
i did bit of research confusion isn't clearing any.
do directly web-page contents , send or can use setting use url? simplest method use , show me example? there risks sending email say... 5000 people , how change header data return link url source?
the following line contents of html page.
$mail->msghtml(file_get_contents('contents.html')); go here full details: http://phpmailer.worxware.com/index.php?pg=exampleagmail
require_once('../class.phpmailer.php'); //include("class.smtp.php"); // optional, gets called within class.phpmailer.php if not loaded $mail = new phpmailer(true); // true param means throw exceptions on errors, need catch $mail->issmtp(); // telling class use smtp try { $mail->host = "mail.yourdomain.com"; // smtp server $mail->smtpdebug = 2; // enables smtp debug information (for testing) $mail->smtpauth = true; // enable smtp authentication $mail->smtpsecure = "tls"; // sets prefix servier $mail->host = "smtp.gmail.com"; // sets gmail smtp server $mail->port = 587; // set smtp port gmail server $mail->username = "yourusername@gmail.com"; // gmail username $mail->password = "yourpassword"; // gmail password $mail->addreplyto('name@yourdomain.com', 'first last'); $mail->addaddress('whoto@otherdomain.com', 'john doe'); $mail->setfrom('name@yourdomain.com', 'first last'); $mail->addreplyto('name@yourdomain.com', 'first last'); $mail->subject = 'phpmailer test subject via mail(), advanced'; $mail->altbody = 'to view message, please use html compatible email viewer!'; // optional - msghtml create alternate automatically $mail->msghtml(file_get_contents('contents.html')); $mail->addattachment('images/phpmailer.gif'); // attachment $mail->addattachment('images/phpmailer_mini.gif'); // attachment $mail->send(); echo "message sent ok\n"; } catch (phpmailerexception $e) { echo $e->errormessage(); //pretty error messages phpmailer } catch (exception $e) { echo $e->getmessage(); //boring error messages else! }
Comments
Post a Comment