Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'Mail.php';
- include('Mail/mime.php');
- $from = 'your gmail id';
- $to = 'your addr';
- $subject = 'Hi!';
- $body = "Well dude, Mail functionality is working isnt it :P.<br/><br/>Now with Attachments";
- $host = 'ssl://smtp.gmail.com';
- $username = 'your gmail id'; // same as $from
- $password = 'your password';
- $headers = array('From' => $from,
- 'To' => $to,
- 'Subject' => $subject
- );
- $mime = new Mail_Mime("\n");
- $mime->setHTMLBody($body);
- $mime->addAttachment("a picture or any other attachment link");
- $body = $mime->get();
- $headers = $mime->headers($headers);
- $email = Mail::factory('smtp',
- array('host' => $host,
- 'auth' => true,
- 'username' => $username,
- 'password' => $password,
- 'port' => 465
- )
- );
- $result = $email->send($to, $headers, $body);
- if(PEAR::isError($result))
- echo 'Error occurred: ' . $result->getMessage();
- else
- echo 'Email sent.';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement