On my computer, is it possible to send emails to my email clients completely offline?

0

I use EasyPHP as a devserver on my computer. And for testing purpose, I have been using PHP mail() function to send emails from my computer to my Gmail account and then receive those emails by using email clients (Microsoft Outlook, Mozilla Thunderbird, IBM Lotus Notes, etc) installed on my computer. That requires internet connection.

I'm wondering if it is possible to send emails directly to my email clients on my computer? That means doing everything completely offline and being without internet connection.

Ian Y.

Posted 2016-08-12T05:32:29.013

Reputation: 103

Answers

1

You cannot send an email directly to the client. The reason is that separate protocols are used for email transfer (SMTP) and email retrieval (POP3 or IMAP). Email clients use the latter. For PHP mail() you need to configure an SMTP server.

If you want to contain everything on a single Windows 7 machine, you can install a local SMTP server like the open source hMailServer and redirect the outgoing SMTP traffic from your application to your the server on your localhost.

You define it as a value of the SMTP parameter in php.ini. On the server side, you must configure the domain (see documentation). You can even configure the same domain as your clients use, so that the only difference is the entry in the php.ini.

Then reconfigure (add profile to) your email client to receive the messages locally via POP3 or IMAP.

techraf

Posted 2016-08-12T05:32:29.013

Reputation: 4 428

Not sure if I understand that correctly, but aren't my email clients' settings supposed to change accordingly? By any chance, is there a step by step tutorial? – Ian Y. – 2016-08-12T07:33:32.493

What do you mean? I wrote you need to "add profile to your email client". – techraf – 2016-08-12T07:35:46.873

My bad. I didn't realize the last line is talking about that. I will try if I'm able to progress. – Ian Y. – 2016-08-12T07:37:42.197

hMailServer documentation is pretty simple, but it's more general. You shouldn't have problems configuring it on localhost. And you can always ask on SuperUser if you run into a problem. – techraf – 2016-08-12T07:40:02.933

In your case for hMailServer it should be enough to install, perform the configuration from the "domains & accounts" section in the included link, add a profile to your mail client. All other defaults should work. – techraf – 2016-08-12T07:52:42.540

After setting up hMailServer and adding a test account, I'm able to use the test account to send emails to itself and receive those emails in my email clients. I feel I'm close. Now I need to be able to use PHP mail() function to send emails to the test account. However, after I changed the value of the SMTP parameter to localhost (the same value I set for the SMTP server fields in profiles in my email clients) in php.ini and tried sending an email, PHP shows this error: Warning: mail(): SMTP server response: 530 SMTP authentication is required. ...... Could you please advise? – Ian Y. – 2016-08-12T10:19:27.547

Problem solved. After I unchecked the "External to local e-mail addresses" option in the authentication setting of hMailServer, everything works fine. Thank you very much! – Ian Y. – 2016-08-12T10:42:17.720

Well done! Glad it worked for you, enjoy coding now ;-) – techraf – 2016-08-12T11:16:57.123

1

For that you would need to setup a DNS server that would include the relevant DNS zones for the target domains whose MX records would point locally, an MTA (mail transfer agent) to receive the messages, and an email server (POP or IMAP) that would allow connection from your email client for email retrieval.

Note that this would be extremely complicated for most people, especially if you've never done anything similar before. It would also be quite pointless, inefficient, and need to be stopped when connecting to the Internet as it would stop you from actually sending mail to those domains.

Julie Pelletier

Posted 2016-08-12T05:32:29.013

Reputation: 2 065

I guess this method is for expert and is not what I'm able to do currently. Thank you anyway. – Ian Y. – 2016-08-12T07:30:04.260