Is there any code provided by google to forward mail. because i haven't found one. If there is any way to forward mail using GMAIL API with extra content to send with original message. Please help.
I don't see any specific forward operation...
You'll have to:
get the message,
add your extra content to the top of the original message and
change the to address, then
remove any cc and bcc addresses [Per #martin-paucot notes from his actual experience doing this]
send it.
Not much help to you but take note of the Threads.
Watch out while doing this procedure !
I used the answer of Jhon Mee to forward all emails from a user to an other one.
If you just change the "To:" it will continue to send the emails to everyone in "Cc:" and "Bcc:"
Here is the procedure:
Retreive the email in raw format
Decode the email from base64
Replace the line "To:" with the email you want to forward to
Remove the lines "CC:" and "Bcc:"
Send it
Alternatively, access through IMAP and use a Python library like imaplib.
#Google Devs: Why not give us easy forwarding through your "Gmail API"?
Related
What is the best way to parse bounced (undeliverable) email?
When an email bounces back to my server, I would like to find why it bounced (soft/hard) and the undeliverable email address. Then I can deal with it appropriately in my database and/or flag the user to update their email when the log in next.
My goal is to protect my domain's mailing reputation. I only send transactional emails, but after time some of those in-boxes go stale and mail bounces back. I don't want to keep sending weekly emails to addresses that bounce.
I couldn't find many recent questions about this, and none had an actual solution:
1) How to parse Delivery Status Notifications emails bounced from Mailer Deamons
2) Automatically remove bounced email addresses from database?
I expected there to be some kind of open source library to help parse undeliverable email, but can't seem to find anything like that. Surely people have been dealing with this issue for a long time...
I would like to deal with this on my server rather than going through services like sendgrid / mandrill / mailgun.
Can anyone point me in the right direction? (I'm using Ubuntu and Postfix)
There are a couple of ways to do this.
1) GREP
It turns out that postfix keeps bounce information in it's log files. All permanent errors will have a dsn status beginning with 5. Using grep, you can get a list of emails with that status code:
grep " dsn=5." /var/log/mail.log | grep -o -P " to=<(.+?)>" | sort | uniq -c
The above gives all hard bounces. For soft bounces, use " dsn=4.".
The upside of this solution is that it is very easy to implement. The downside is we have to rely on postfix to correctly parse the message, and it may not work if you're sending to a mailing list, rather than to individual recipients.
2) VERP
Variable Envelope Return Path (VERP) uses a unique return path for every email recipient. (See wikipedia description)
Note that the 'return path' of an email is NOT the same as 'reply to'. The 'return path' is only used by mail servers to bounce emails back to the originating server when problems occur.
In short, let's say we're sending an email from mymailinglist#mysite.com to richard#exapmle.com. If you send it the normal way, you will get a bounce message and have to parse the message to figure out who it was sent to. But using verp, you set the return path to bouncelist+richard+example.com#mysite.com.
Now you can setup a mailbox specifically for bounced emails (bouncelist#mysite.com). By default postfix ignores anything after the "+" in the email address, so all bounced mail will go to the same place. But now the original email recipient (richard#exapmle.com) is contained in the return path and can be easily parsed out.
If you like, you can also send the mail directly to a script using a virtual mailbox. In /etc/postfix/virtual add the line
bouncelist: "| php mybounceparser.php"
This solution is certainly more complicated to implement, but may be the only option for large mailing lists.
Consider using MailboxValidator free API to screen the email address prior to sending out any emails. It is after all better to avoid bounce if you can.
https://www.mailboxvalidator.com/api-single-validation
That is if you are willing to write some codes.
Otherwise, your other option is to upload a CSV of your mailing list into the MailboxValidator bulk validation page and clean them. Once validation is done, you can download the results and import back into your database.
I have some emails from Mail::POP3Client that I need to send (including attachments) to another email address (essentially, as if it were forwarded from a common email client).
I'm not very familiar with Perl, so I've been looking into this for a while. I'm not sure of the best way to do this; do I need to use RetrieveToFile and then send it with MIME::Lite? Will that be readable by a human and include attachments?
It seems like there has to be a simpler way that I haven't discovered yet. Am I on the right track?
I've done similar things with MIME-tools, which is a similar package. At the time I did that, MIME-Lite didn't exist. But I am sure that MIME-tools can handle what you ask. I can't imagine that MIME-Lite shouldn't be able to do something similar.
Forwarding like a desktop mail client does consists of two parts:
email munging
Use Courriel::Builder to create a new email. Attach the email that you originally received. The appropriate mime_type parameter for the attached email is message/rfc822.
email sending
Use Email::Sender.
You probably want to redirect, not forward the email, though, so that the original sender stays the same and the recipient can easily reply.
Whenever i try to send a mail from my website for email verification, the same is being received in a spam folder. I noticed that plain messages are being received in inbox, but whenever i try to include an ordinary http link[http://abcd.in/abcd/verify.php?key=2f27feb552c83c6c65b9bfc4d799e775], the mail goes to the spam folder. Cant point out the reason why this is happening. Please help me to resolve this issue.
Thanks All
From experience, I know that the spam score can be affected when hyperlinks have an alphanumeric argument tagged onto the end. I suggest trying to reformat the URL into something like;
http://abcd.in/abcd/f27feb552c83c6c65b9bfc4d799e775/verify.php
and extracting the reference using a Regex or Split()
Is your outgoing mail server configured to receive mail?
Are you using a proper mail server with proper setup at all or some bulk-mail-sending dud?
Are your mails sent with a real from address? And I don't mean the header-from that you can add in your software, but the protocol-from that is being used by sendmail
Do you have domain keys/dkim set up for your mail server?
Is the header OR the protocol from address from a different domain? Do they have set up domain keys allowing your mailserver?
Does your mail server feature the same domain name on the reverse lookup?
Does your mail server offer to receive mail for the user they are sending for?
Is your webhost using a smart relay? Do they rewrite the from: address?
Or do you send mails with internal mail address from?
A forum-like app I'm working on will send an email notification to the thread starter when a new replied is received. It would be nice if the owner can just reply the email to add a new reply to the thread.
How can I implement the feature, i.e. "reply to this email to comment" like Facebook?
Option A: scan the subject line/body? I don't like it 'cause what if the user modified the subject line by mistake?
Option B: use a unique reply-to e-mail address that links to the thread ID. Is this a common function for mail server? like set up a *#addComment.domain.com ? Or does the app server needs to setup a new email account before sending the email with reply-to?
Any other options?
Thanks!
Using strings in the subject and body can be easily erased by a user of the system.
Use plus addressing (reply+UNIQUEIDENTIFIER#yourapplication.com) as the REPLY-TO address in the mail message. With CFIMAP you can retrieve the messages and parse the TO.
Wildcard domain (replyto#UNIQUEIDENTIFIER.yourapplication.com) is also an option, but if your email server supports plus addressing I would go that route.
You could stuff the thread ID or the parent message ID (the message that is being replied to) in the Msgessage-ID: header of the email, or a custom email header, and put the processing after accepting the message.
However, using custom Reply-To: addresses is quite common.
an option is to embed an identifier in both the subject and the body of the original email. something small, like bit.ly's 6-8 character code. that way, they're less likely to mess it up, and you have the safety of the email body, which most people leave in anyway.
Using a custom email header is not advised as there is no guarantee that any server along the route would not strip it off (or simply fail to pass it on). A friend who worked at a huge email data center for AT&T said the techs there warned him off that idea.
This may also be true of the Message-ID: -- don't know.
I have a situation where emails bound for several recipients will arrive in one mailbox.
I want to go through and deal with them according to who they were sent to, but I'm not sure I will always have the correct info.
Suppose I have one recipient fred#domain1.com .
if someone bcc's him on an email, I know that fred will not see any To: field in his email BUT I will be able to find fred#domain1.com in the envelope. No problem.
Now, what if fred has some email forwarding service. Or lets say he asks gmail to forward a copy of every email he receives at gmail on to his fred#domain1.com address.
The original message that was sent to him may have said fred#gmail.com in the envelope, and will still say it in the To: but once gmail has forwarded it, can I be sure I will always find fred#domain1.com in the envelope for the "final leg" of its journey ?
fred#gmail.com it would be no use to me, you see.
Or will I find (somewhere in the envelope) references to both the gmail AND the domain1 addresses ?
TIA
I believe MTAs add Delivered-To or X-Forwarded (or similar, depends on the MTA) for the forwarded message. To: headers usually stay as-is.