Created
November 5, 2012 20:43
-
-
Save webbyfox/4020226 to your computer and use it in GitHub Desktop.
Sending email via Gmail using Google SMTP server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ERROR); | |
require_once "Mail.php"; | |
$lines = file('orders.txt'); | |
echo "sending emails..."; | |
foreach ($lines as $line_num => $line) { | |
$line_array = explode(" ", $line); | |
echo $line_array[5]; | |
$order_id = $line_array[0]; | |
$full_name = $line_array[5]; | |
$email = $line_array[4]; | |
$product_sku = $line_array[7]; | |
$product_title= $line_array[8]; | |
$mail = NULL; | |
$asin= NULL; | |
$buyername=$line_array[5]; | |
$to = "<[email protected]>"; | |
$subject = "Hi!"; | |
$message = <<<EOT | |
<html> | |
<head> | |
<title>Birthday Reminders for August</title> | |
</head> | |
<body> | |
Dear $buyername, <br/><br/> | |
Amazon Order ID: $order_id <br/><br/> | |
Product Name: $product_title<br/><br/> | |
Thank you for your recent purchase from Micropix through Amazon. It been couple of weeks since you have placed your order with us and we were hoping you would let us, and everyone else, know what you think of our products. Your opinion is important to us.<br/><br/> | |
We invite you to submit a “Product Review” for the item you have purchased that would benefit other customers to choose the best products on Amazon. <br/><br/> | |
The following steps are Easy Guides to leave the Customer Review for the product that you have purchased from Amazon. <br/><br/> | |
Click on the Write a Review button or link below. <br/><br/> | |
<div style="align:center;" > | |
<a href="www.amazon.co.uk/review/create-review/ref=cm_cr_dp_wrt_top?ie=UTF8&channel=rw-dp&asin=$asin" > | |
<img alt="www.amazon.co.uk/review/create-review/ref=cm_cr_dp_wrt_top?ie=UTF8&channel=rw-dp&asin=$asin" title="alt="www.amazon.co.uk/review/create-review/ref=cm_cr_dp_wrt_top?ie=UTF8&channel=rw-dp&asin=$asin"" src="https://zdub-cd-03.s3-external-3.amazonaws.com/AJY84FSBCZUXU%2FXR4tJbM%2Fknp30lALVCx8YBdy%2B4AiiXCBFhkYigRQKVTg1j4qjJvgWMHRDD0C2UbFUZFh58DxP3iU2RNu7g%2FBU8%2Fw7Ria1NNbfbELEgG4OhKmrwu5Denxrto%2B%2F%2BhcykLxhlLob1Tz8k5puC06l8RMuC8bcJCfMMhibC%2FcONf7XBm3xw%2F9iJzBbZyj%2FRAZc6Vz6AU32OWQTbbFKSp819F84ynWxYqo6vOPXQuZLXzlT4tVBux%2FcrdHzVqud7NyIfa7WpFtFQpSk78tWSzJc%2F9LRVYO7pkXLG%2F8jZJYuIzcGYPcxhEkLsOkrDIp7w%2FkekAkogSDHb0l8QM4O6cLsEDMRQ%3D%3D%2F300x78.jpg?Expires=1352176500&response-expires=Tue%2C%2006%20Nov%202012%2004%3A35%3A00%20GMT&response-content-disposition=filename%3D%22300x78.jpg%22&x-amz-security-token=AQoDYXdzEKv%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEawAOHpT1chh%2BP9t%2BTX%2FWGizA6a1%2FVop1NlC9qULqT3LefNzgz0Zc0n4R4syYxEnSkibDpYT9tiMTvNn0kRodMRi2zfEpKWYPbJFR7KNcAh1cF7tF1Jh2YKSsPb%2B3O14RmNwDkOz2iATw0P5I3dygghFSFlRVrOvL8kyMmMKZMMjkfuNsTEMMeRUd4pyrEje1ogL1Rvp5qphs7hpko71L1UJf1ZeBlhP5f6kz%2FeFv3fP%2FHYQReNZ3i5MOK%2FS%2FrcEdChqLczJklk5tWemCXZ8y9sQ6Owm5JMp%2F6xerG03lIDoAMckSJEKQRF2aOg2Pv0DYMcjcsCIDDI0%2B6wX1IDfqwg5kis83KjJ4UI5krGmikn8pBkllpf%2FjqDYBfLk8ZxqVrO0pyOgYTAcJM%2Fc2K24UWrVevD%2BR%2FynBTnj%2BmLbReW5qYq4e1owGX1OCyr4JMBBeQ%2BlQnQfHKkjnOEgSFORXU%2B0%2FUJJcLC%2BFToV2RHoPwRnyk0HxWEOKvxPq7W6yCoX0OIoDWebjXObMfKkdBGIQOltZR3jFpHLvK%2FAP12fiIX9cCGej3nxwmM5u12Qo6x9bmk7PS7Bkl7eNrO%2F7jxh6qiPhmIK7a2oQF&AWSAccessKeyId=ASIAIODRLHG3ZSD6ECFA&Signature=Y%2FDMgNP42BCOXzFnLW%2FX8kcxPUg%3D"/> | |
</a> | |
</div> <br/><br/> | |
link: www.amazon.co.uk/review/create-review/ref=cm_cr_dp_wrt_top?ie=UTF8&channel=rw-dp&asin=$asin | |
<br/><br/> | |
Log into your Amazon.co.uk account if prompted. <br/><br/> | |
In the <b>Share your opinion</b> section, click the radio button for the type of review you wish to submit. | |
Preview and complete your review. <br/><br/> | |
If you have any problems with your order, please email us by providing your Amazon Order ID: [orderid] and we will be happy to help. <br/><br/> | |
Your Sincerely <br/><br/> | |
Zara Raynal <br/> | |
Customer Servvices Manager <br/> | |
Micropix <br/> | |
<br/> <br/> | |
</body> | |
</html> | |
EOT; | |
$host = "ssl://smtp.gmail.com"; | |
$port = "465"; | |
$username = "[email protected]"; | |
$password = "c0mput3r"; | |
$headers = array("MIME-Version"=> '1.0', | |
"Content-type" => "text/html; charset=iso-8859-1", | |
"From" => '<[email protected]>', | |
"To" => '<[email protected]>', | |
"Subject" => $subject); | |
$smtp = Mail::factory('smtp', | |
array ('host' => $host, | |
'port' => $port, | |
'auth' => true, | |
'username' => $username, | |
'password' => $password)); | |
$mail= $smtp->send($to, $headers, $message); | |
if (PEAR::isError($mail)) { | |
echo("<p>" . $mail->getMessage() . "</p>"); | |
} else { | |
echo("<p>Messages successfully sent!</p>"); | |
} | |
} | |
?> <!-- end of php tag--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment