I need to send mail from my PHP app, I wonder if I authenticate as a exchange user via PHPMailer, does my mails send from my app will be on the outbox in the MS Outlook of this user ?
Thanks
On most mail servers, no, this doesn't happen automatically, but you can do it yourself. The gmail example provided with PHPMailer shows how to save a sent message to your outbox using IMAP; it will be nearly identical for Outlook. Alternatively, BCC the original message to yourself and you'll receive a copy of everything you send, which provides a similar effect.
Related
I've a drupal 7 site, and requires a functionality by which I can read emails from gmail inbox whenever they arrives. Currently I'm achieving it with php imap by running it on cron.
But I want something, which can read email from inbox as soon as it arrives.
Please suggest, thanks
This would be a bit of a round-the-houses approach but create an account with mailgun.com. Within Mailgun you can then direct incoming emails to a URL you specify. Mailgun parses the email and sends it to you in a structured format.
You could then set up your Gmail account to send a copy of all incoming emails to your Mailgun account.
I am developing a lightweight Gmail client for mobile phones, accessing Gmail by IMAP. I want to send a draft from the Drafts folder, but it has some attachments and I cannot download all of them to send it by SMTP.
Moving/copying it to "Sent Mail" does not send it, just moves it to that folder.
How can I send a Draft directly without fetching all the content and attachments from the client? Is there any IMAP command to do it?
IMAP is a mailbox protocol. It does not (natively) support sending mail, only accessing it. In order to send mail you must use SMTP. Its possible that there is an IMAP extension for sending mail, and its possible that Google Mail supports that extension, but I doubt it. Hence, if you want to send an email with attachments, you must actually have the full content of the message available to you to send.
IMAP was designed to receive email messages, not to send it. There is no IMAP command for sending email AFAIK. There is, however, at least one IMAP server which supports a special 'Outbox' folder. When you place the message into this folder it will be sent automatically.
Check Courier-IMAP documentation on Sending mail via an IMAP connection. Note, that this is a non standard method and I'm not aware of any other server which supports this.
There RFC 4468 which extends SMTP so it can fetch the mail content from the IMAP server, but I don't know about any working and widely used implementation.
Talking about gmail: sticking with SMTP is probably the safest way to go.
By the way, now that any modern mail client (including the webbased ones) supports a Sent folder, you typicaly have to use both SMTP and IMAP to send a single mail. And there's a race condition between sending the e-mail over SMTP and successfully saving the e-mail to the IMAP Sent folder. Using IMAP for sending e-mail is a way to avoid this race condition.
Sending email is a special feature of some imap servers. Its nothing in the imap protocol. You just copy your email into a special imap directory on the server and it sends them. I doubt that gmail supports this.
I sent an email to my own email address using IMAP using Python 3 to a gmail account. What is does is append a message to a mailbox. You need to utilize a handful of Python's native libraries. Also study this documentation for imaplib, this code is featured in the section Uploading Messages: To add a new message to a mailbox, construct a Message instance and pass it to the append() method, along with the timestamp for the message.
Then check your gmail inbox and you'll see the new message.
import imaplib
import time
import email.message
import imaplib_connect
new_message = email.message.Message()
new_message.set_unixfrom('name')
new_message['Subject'] = 'Test'
new_message['From'] = 'name#gmail.com'
new_message['To'] = 'name#gmail.com'
new_message.set_payload('This is an example message body.\n')
print(new_message)
with imaplib_connect.open_connection() as c:
c.append('INBOX', '',
imaplib.Time2Internaldate(time.time()),
str(new_message).encode('utf-8'))
# Show the headers for all messages in the mailbox
c.select('INBOX')
typ, [msg_ids] = c.search(None, 'ALL')
for num in msg_ids.split():
typ, msg_data = c.fetch(num, '(BODY.PEEK[HEADER])')
for response_part in msg_data:
if isinstance(response_part, tuple):
print('\n{}:'.format(num))
print(response_part[1])
I want to send message from my mail server, for example from. Can i use for that PHP Mailer class? And how STTP server checks the correctness of email? only checks that domain belongs one of his existing domains?
Sorry for bad english ))
Yes you can use phpmailer. You need to put in the smtp information provided by your hosting company in order to send the email
I have a webpage that sends out emails using phpmailer. I set the host to 'relay-hosting.secureserver.net' the mail->sender, mail->from and mail->addReplyTo all to the same address, which is the address that I want the bounced email notifications sent to. This email address in also with the same host and the smtp host. When I put in a bad email address I don't get a notification that is was not delivered. What am I doing wrong? Thanks
PHPmailer does not handle receiving emails. It's purely a library for allowing PHP to talk to an SMTP server for sending emails. It has absolutely no support whatsoever to act as a mail client (e.g. receiving).
PHPmailer has no way of knowing the email bounced, as the bounce occurs LONG after PHPmailer's handed the email off to the outgoing SMTP server. IN real world terms, PHPmailer takes your letter and walks down the block to drop it into a mailbox. The bounce occurs later, when the letter carrier brings the letter back with 'return to sender' stamped on it - PHPmailer is not involved in this at all.
Your options are:
1) Use PHP's imap functions to connect to an existing pop/imap server and retrieve emails that way
2) Use a .forward or similar redirect on the SMTP side to "send" incoming email to a PHP script.
I know this is an old and answered question, but for those who may find this post later with a similar problem you might be able to solve this by going to your smtp mail relay service. If for example you use jangosmtp there is an option in your jangosmtp control panel to either hard code the address to which bounce reports should be sent or to always send bounce reports to the From address.
I'm using PHPMailer for sending activation codes to users. As far as I know, that's best script for this purpose. Today noticed that, some users doesn't receive activation codes. But mailer return "Succesfully sent" message. Is there any chance that, phpmailer can't send to some mail servers? Or which is the best php script for sending mail via smtp authentification in your opinion?
It's not obvious that it is PHPMailer problem. It has connected to your smtp server and successfully sent the message. By successfully I mean that your server has accepted it. What happens next is a mystery and you have no control over it.
Few common reasons of undelivered mail:
marked as SPAM by foreign server (advise users to check their spam folder)
target mailbox does not exist (typos in username etc)
user inbox is full and will not accept new mail
mail queue on the server is quite big and it will take few minutes / hours to deliver
The best you can do is to advise users to keep their mailboxes clean, check their spam folder, retype email to prevent typos and offer a service for re-sending the activation email.
I send registration and activation emails using SwiftMailer via Google Apps Mail (support#mydomain.com). It works like a charm, easy to setup, and has no delivery issues since it's using Google's servers. Check it out.