Laravel save a copy of the email on storage - email

I'm sending emails in Laravel with mandrill but I also want to save a copy of the email on the storage also (like mailoutput but in my own log folder)
Do you have any idea how to do that?
Thank you

Though you can log mails in Laravel, it seems that emails will not actually be sent at the same time.
A simple solution would be to log emails yourself:
Find where you send emails and add customized logging statements.
Mail::send('emails.welcome', array('key' => 'value'), function($message)
{
$message->to('foo#example.com', 'John Smith')->subject('Welcome!');
Log::info('You email content and receivers here');
});

Related

Sendgrid - add email attachments via dynamic templates

I am using Sendgrid API v3 in a node.js and express environment.
I am using email dynamic templates and easily I can send custom text to the email templates.
But I need also to add attachments and I can't find documentation about that. I need to add attachments in 2 different ways:
There are email that need to have always the same attachments and it would be good for the email template to have its own attachments that is send to the customer inbox not matter what is the server data sent to sendgrid.
If a clinet buys an ebook, this file should be sent by the server, together with the rest of {{{data}}} to Sendgrid and this specific file should be delivered to the client as an attachments.
Can anyone say how to add attachments this way?
Thanks
Not sure if you still need it. But you can send emails using Dynamic Template and Attachments. Reference with their API Doc.
Sample code:
const sgMail = require('#sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const fs = require("fs");
pathToAttachment = `${__dirname}/attachment.pdf`;
attachment = fs.readFileSync(pathToAttachment).toString("base64");
const msg = {
to: 'test#example.com',
from: 'test#example.com',
subject: 'Sending with SendGrid is Fun',
templateId: "d-11111111111111111111111111",
attachments: [
{
content: attachment,
filename: "attachment.pdf",
type: "application/pdf",
disposition: "attachment"
}
]
};
sgMail.send(msg).catch(err => {
console.log(err);
});
For your 2 cases, why not build a function to send emails with parameters of dynamic template ID and attachments?
sendEmail(
templateId: string,
attachments: Attachment
)
Sendgrid attachments are limited to 30mb which might be too small for what you are trying to do. Sendgrid let's you use the digioh api to send files up to 2gb.
https://digioh.com/sendgrid
An alternative solution would be to send a callback url as text in the email that is linked to an endpoint on your express server that let's users download the data. In this case you would need some additional setup to make sure only users who purchased the items can download them.

S22 imap fetch mails from office365

I'm using s22.Imap referance for fetch new mails from server. While read exchange server everything was perfect. But we were moved to office365. Now I can't read new mails from my project. Here is small codes.
using (ImapClient client = new ImapClient("outlook.office365.com", 993, user, pass, AuthMethod.Login, true)) {
// Returns a collection of identifiers of all mails matching the specified search criteria.
IEnumerable<uint> uids = client.Search(SearchCondition.New());
// Download mail messages from the default mailbox.
IEnumerable<MailMessage> messages = client.GetMessages(uids);
foreach (MailMessage item in messages) { blablabla }
This part return this error : The stream could not be read.
Lastly I'm using this codes in windows service application. So I'm not clearly debuging.
Is anyone help me ?
Office365 does not support AuthMethod.Login. Try AuthMethod.Plain or try using a different IMAP library like my MailKit library which is more actively maintained.
Hope that helps.
its possible but I think that the suscription of the account should be
Exchange Online, instead of a classic suscription
I do the same with S22 library, but we request to change the configuration of the mail to accept imap conection

Magento print transcational emali before mail send

is it possible to print transaction email body before email send? I just want to see how to display layout after display value in transactional email.
All Magento emails are send through this method: Mage_Core_Model_Email_Template::send().
Here is how I usually check my e-mail templates. In the method mentioned above, right after these lines:
if($this->isPlain()) {
$mail->setBodyText($text);
} else {
$mail->setBodyHTML($text);
}
I add this:
echo $text;exit;
instead of sending an e-mail it just prints it in the browser.
Don't forget to remove this line after you're done testing.
If you want to use the this in a live environment and save all the send e-mails you will have to do a more elaborate thing, live overriding the class, and not stopping the script at all, but you can do all this in the same place.

Emails sent through joomla go to SPAM folder

I am using the latest Joomla build for my website.
Allso we use a DNS record for having the mail delivered to our own server instead of the server on which the website is hosted.
I have used several contact form components, but every sent mail goes to my SPAM folder.
After searching hours on the web (and getting linked to this site frequently) i decided to make a new post.
It does not matter if i use the standard joomla forms, or any component.
Whenever a user fills in a form on my website, the email gets sent. The user receives a copy of its message, and i receive the message of the user. However, this message gets thrown in the spam folder, as phishing.
The sender of the mail always is: username#nameserver.i3d.net; namens; websitename
What do i have to change/enable/disable for this to work?
Thanks in advance.
Patrick.
(Sorry, I'm new to Joomla, but it uses PHP, so this may apply. Also this answer got a little long...)
It might be an issue with the email headers. A lot of email clients will automatically spam-box all mail where the address in the From: header doesn't match the envelope sender. As an analogy, you might not trust a snail-mail letter signed "Your Rich Uncle", mailed in an envelope with a Nigerian return address. Also if your envelope sender has a different domain than the one the email is actually sent from, that's another quick ticket to the junk bin. For more info about Gmail's message blocking policies (and general good practices), you can try this help page.
Here's some basic PHP email-sending code:
$to = $userEmailAddress;
$subj = $emailSubject;
$mesg = $emailMessage;
$headers = implode("\r\n",array(
"MIME-Version: 1.0"
,"Content-type: text/html;charset=iso-8859-1"
,"From: WEB_ADMIN_NICE_NAME <WEB_ADMIN#YOURSERVER.COM>" // *** 'From:' header
));
$from = "-fWEB_ADMIN#YOURSERVER.COM"; // *** envelope sender
if(!mail($to, $subj, $text, $headers, $from)){
//Some error handling...
}
On the first line I commented, you'll want to replace WEB_ADMIN_NICE_NAME with the name you want the email recipient to see (e.g. "Bill Gates"), and on both lines, replace WEB_ADMIN#YOURSERVER.COM with the actual return address (e.g. "da_boss#microsoft.com"). Note: whatever address you choose for the return address is where users' replies will be sent.
To reiterate, make sure both lines have the same return address (though the nice name can be anything you like), and make sure that the actual server sending the mail is in fact located at YOURSERVER.COM.
Lastly, I'm not sure where Joomla does its mailing, but if you're totally lost, you can try grepping with -lr for 'mail[[:space:]]*('.
there are several reasons that could make your email look suspicious to spam filters; to find out which head on to:
http://www.mail-tester.com
grab the email address and send an email from your website to it.
Then go back to the page and it will tell you what's wrong.
btw I'm struggling with the same issue,my problem being that on Joomla 2.5.9 apparently when you send html emails, a text-only copy is not added to the message, which is considered "spammish behaviour"
The problem is the i3d.net email address. My personal experience is that their network (31.204.154.0 - 31.204.155.255) is a significant source of spam and they do not action abuse reports. I suggest changing your hosting company.

CakePHP emails being sent as text instead of html

We recently switched to a new server and now when we send out our email blasts through cakePHP, users who were receiving email as html before are now getting them as code. Any thoughts?
You can configure the format in your controller:
//Send as 'html', 'text' or 'both' (default is 'text')
$this->Email->sendAs = 'both'; // because we like to send pretty mail
// more code here
$this->Email->send();
If this was triggered by a server move, it's possible that you are missing a file rather than a line of code. In that, case, make sure you have layouts setup for both types of email. Here is the file structure to check:
app/views/layouts/email/
html/
default.ctp
text/
default.ctp
For more from the cookbook:
http://book.cakephp.org/view/1286/Sending-a-basic-message