Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sendmail($file,$mailto)
- {
- $mailer =& JFactory::getMailer();
- //var_dump($mailer); exit;
- $config =&JFactory::getConfig();
- $sender = array(
- $config->getValue( 'config.mailfrom' ),
- $config->getValue( 'config.fromname' )
- );
- $mailer->setSender($sender);
- $recipient = array($mailto);
- $mailer->addRecipient($recipient);
- $body = "Your body stringnin double quotes if you want to parse the nnewlines etc";
- $mailer->setSubject('Your subject string');
- $mailer->setBody($body);
- // Optional file attached
- $mailer->addAttachment(JPATH_BASE.DS.'CSV'.DS.$file);
- $send =&$mailer->Send();
- if ( $send !== true ) {
- echo 'Error sending email: ' . $send->message;
- } else {
- echo 'Mail sent';
- }
- }
- $from="noreplay@gmail.com";//Please set Proper email id
- $fromname="noreplay";
- $to ='admin@gmail.com';
- // Set a you want send email to
- $subject = "Download";
- $message = "Thank you For Downloading";
- $attachment = JPATH_BASE.'/media/demo.pdf';
- // set a file path
- $res = JFactory::getMailer()->sendMail($from, $fromname, $to,$subject, $message,$mode=1,$cc = null, $bcc = null, $attachment);
- if($res)
- {
- $errormsg = "Mail Successfully Send";
- }
- else
- {
- $errormsg ="Mail Not Send";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement