Hi there,
I am stuck and at a complete loss, hope you can help. I am generating an email from the system using Joomla!'s JMail class. I have done this 100 times before, but this time, it just doesn't want to work correctly.
Where the issues lies is in the attachment. No error is thrown, and the attachment is not attached. The message goes through fine otherwise. I turned on site debugging and still received no errors or other indications of why the attachment is simply omitted. I have also tried moving the file to various different directories and referencing it's location differently with no luck. Here is a modified version of my code:
// create a mailer object
$mailer = JFactory::getMailer();
// content is HTML
$mailer->isHTML(true);
$mailer->Encoding = 'base64';
// set the sender to the site default
$config = JFactory::getConfig();
$sender = array(
$config->get( 'config.mailfrom' ),
$config->get( 'config.fromname' )
);
$mailer->setSender($sender);
// set the recipient
$mailer->addRecipient($registrant->email);
// set CCs
if(!empty($registrant->cc)){
$mailer->addCC($registrant->cc);
}
// set the message subject
$mailer->setSubject('Test Email With Attachment');
// set the message body
$message = 'This is an example message';
$mailer->setBody($message);
// add the attachment
$mailer->addAttachment('agenda.pdf'); // the attachment is in the same directory as this script
// send the message
if($mailer->Send()){
// success
}else{
// fail
}
The send function succeeds and the message is sent, the only issue is that there is no attachment and no error. I looked through the PHPMailer class and it supports PDF, so I don't think that is the issue, and I am using this identical method to send .ics files in other modules without trouble.
Any guidance on debugging would be great. Thank you for your time.