I am sending emails with phpmailer package and using the package with codeigniter framework. I have made a helper function out of the phpmailer package which takes arguments as sender's address, recipient's address, subject and message body. Everything goes fine and the message is delivered to the inbox.
My problem is I have a large body which can be a seperate html file. For this I have created a view and I am trying to send the argument $this->load->view('viewname'); through the helper function in my controller. But instead of displaying the body in mail I get the file displayed on my final view page and the mail body goes blank. Any idea how I can achieve
Using $this->load->view('viewname'); without any additional parameters will output the view. What you need is to set the third parameter to TRUE as suggested in the Returning views as data of the CodeIgniter User Guide's View documentation.
Example:
$string = $this->load->view('viewname', '', true);
Related
I'm trying to track emails sent via laravel mailgun driver. I want to be able to view the emails in the 'analytics' page of app.mailgun.com.
I am able to send emails using Postman with the following headers: o:tag o:tracking o:tracking-clicks o:tracking-opens and these seem to work fine. I can see these in the 'analytics' page. I have also successfully set up web hooks so I can track individual events for each email.
According to the documentation if I am sending via SMTP I need to send these tags: X-Mailgun-Track: yes, X-Mailgun-Track-Opens = yes. I have set these using the following code in the build method of my mailable class:
$this->withSwiftMessage(function ($message) {
$message->getHeaders()->addTextHeader(
'X-Mailgun-Track', 'yes'
);
$message->getHeaders()->addTextHeader(
'X-Mailgun-Track-Opens', 'yes'
);
});
I can see these headers are added when I open the email in a text editor. The email does not show up in the mailgun 'analytics' page.
Any help on this would be appreciated. Thanks!
I am successfully able to attach inline image for my system email. I am using template which I have created in mailjet Transactional templates. Now if I use attached image in html but I am not able to see image in my email.
I am sending inline image like this which is working perfectly.
$logoFile = 'full path of image';
$inlineImg[] = [
'Content-type' => 'image/png',
'Filename' => 'logo.png',
'content' => base64_encode(file_get_contents($logoFile))
];
'Inline_attachments' = $inlineImg;
Now, I want to see this image in my email. Using image in mailjet template like this:
<p>Test inline image <img src="cid:logo.png" /></p>
Ref: https://dev.mailjet.com/guides/?php#sending-with-attached-files
I sent them a support ticket after I ran into this problem myself. They are aware of it and working on it.
According to them, inline attached images are displayed on all major email clients except Thunderbird and GSuite (the professional version of Gmail, apparently). Their test email (the curl command in the documentation you refer to) does work with Gmail.
In which email clients do you observe issue? There is a known issue with inline attachments not rendered properly in Thunderbird and few other minor mail clients due to the required specific "Content-type" by the mail client. Inline images should be displayed properly in all major email web services - Gmail, Yahoo etc. If one of the latter platforms are affected, please open support ticket for additional investigation.
I need to send a link within HTML email using CodeIgniter.
first trial:-
send an email to using Gmail server, then the link will be sent successfully without any corruption.
Second trial:
I am using Microsoft Exchange Server.
when sending the link within the HTML email, the link will be received corruptly!!
I don't know why? Then the problem occurred when using only Exchange server.
correct link
http://000.00.0.00/s/admin/r?i=7&e=hana#dom.edu.com
corrupted link
http://000.00.0.00/s/admin/r?i=7&e=hana#do=.edu.com
If I put it within a href tag
correct link
http://000.00.0.00/s/admin/r?i=7&e=2
corrected link
http://000.00.0.00/s/admin/r=i=7&e=2
My IP= 000.00.0.00, it is not the actual but it is just an example
You have to change the crlf setting to use Exchange as an SMTP server.
Add $this->email->set_crlf( "\r\n" );to your controller or add $config['crlf'] = "\r\n"; to your email config file!
The equal signs getting substituted into your email message are a dead giveaway that the end of line character is the issue.
I'm trying to set up a contact form for a client who wish to link the data from the form into their Goldmine system.
There is a 3rd party company who have sent me a sample contact form and a sample PHPMailer script, but when I test this script on the client's website it sends out the email, but as an attachment rather than in the body of the email.
I've looked at the PHPMailer script and I cannot see anywhere that references adding attachments so I'm puzzled as to whether there is something in the PHPMailer script I've not seen, or if this is some sort of server setting when the email is being sent? Any help would be appreciated.
The PHPMailer script has $Body which it just keeps adding each part of the form input to and then finally ends with what looks like the relevant bit of code to send the email:
ini_set("SMTP", Decode($SMTP));
if(mail(Decode($SendToEmail), $ToSubject, $Body, "From: GoldMine WebImport <no-reply#xxxxxxx>\r\nContent-Type: text/x-gm-impdata\r\n" )) {
print "Your data has been recorded successfully!\n\n<!--\n".Decode($SendToEmail)."\n".$ToSubject."\n".$Body."\n\n".$OutputAs."\n\n-->";
}
else
{print("There was a mailer failure.\n\n<!--\n".$Body."\n\n-->");}
}
else
{echo "There was no form data passed.";}
EDIT: I should also mention that I've been using Tectite's Formmail system for the same client on their existing contact forms and that sends the email with the content in the main body of the email as it is supposed to. I only seem to be having this problem with PHPMailer, but I can't use Formmail for sending the right info to the Goldmine system.
I use PHPMailer to send email via SMTP. It works, but it doesn't save the sent emails in
sent items. I want to make to sent emails in the sent items, any idea?
I know can use imap_append function to achieve it. But, how to do that?
The PHPMailer seems doesn't has the function to return the $message.
if ($return = $mail->Send()) {
$stream = imap_open("{{$host}:993/imap/ssl}Sent Items", $user_name, $user_pwd);
imap_append($stream, "{{$host}:993/imap/ssl}Sent Items" , $message , "\\Seen");
imap_close($stream);
};
How to get the message body from PHPMailer?
The instance variables from PHPMailer are all public.
Looking at the source you can just use:
$mail->Body
If you want the plain body including the all boundaries you could also use:
$mail->CreateBody();
See:
http://phpmailer.svn.sourceforge.net/viewvc/phpmailer/trunk/phpmailer/class.phpmailer.php?revision=452&view=markup
The PHPMailer seems doesn't has the function to return the $message.
Yes, it does. At least in version 5.2.28 there is a method getSentMIMEMessage() to get the full MIME message (different from the email body). That method only works after sending the email, or calling the preSend() method.