This is the code for my attachfile Message.
Code: Select all
public function attachFile($path_to_file,$file_type, $message,$subject = ''){
if( get_class($message) == 'Swift_Message'){
$messageObj = $message;
$message->attach(new Swift_Message_Attachment( new Swift_File($path_to_file),$path_to_file,$file_type));
}else{
if(!empty($subject)){
$messageObj = new Swift_Message($subject);
}else{
$messageObj = new Swift_Message($this->subject);
}
$message->attach(new Swift_Message_Attachment( new Swift_File($path_to_file),$path_to_file,$file_type));
}
return $message;
}
Code: Select all
$message2 = "<html>" ."<head><title>OptionIT<title></head>"."<body>" .
"<div style='float:justify;font-size:.8em;font-face:Arial,Verdana;'><span>Hi Sai,</span></div>" .
"<div><p align='center'><div style='float:justify;font-size:.8em;font-face:Arial,Verdana;'><span>This is a test mail for single plain html mail</span></div></p>" .
"<p><div style='float:justify;font-size:.8em;font-face:Arial,Verdana;'>Thank You</div><p></div></body><html>";
$to_email2 = "xxxxxxxxxx@azzx.com";
$from_email2 = "yyyyyyyyy@yyy.com";
$msgObj2 = $this->message('Single Email with Attachment',$message2);
$attached_msg = $this->attachFile(CONTROLLER_DIR."/files/file.jpg", "image/jpeg",$msgObj2);
if($this->sendMail($attached_msg,$to_email2,$from_email2)){
echo "Message to Single Email Sent";
}else{
echo "Message to Single Email Failed";
}
Code: Select all
[mimeWarning:protected] => This is a message in multipart MIME format. Your mail client should not be displaying this. Consider upgrading your mail client to view this message correctly