Why PHPMailer needs an SMTP to send emails and postfix doesn't - php

i just installed postfix: it's sending email without any configuration by me. (I choosed no-config
setup)
Can I know why phpmailer needs a valid smpt or relay to send emails while postfix doens't?
Thanks

postfix is a mail server. phpmailer is a library to interface with a mail server.

Because postfix is a SMTP server.

Yes, well congratz, you have build yourself kind of an open relay then:)
Phpmailer needs server config as far as I could for now see when stumbling over their docs.
Postfix is a mail server which would be a layer under this, I suppose.

Related

Laravel 4 Mail - failed SMTP on server, switching to mail method

This is quite strange as email sending using my Gmail SMTP server works in my localhost, but when I deployed it on a VPS, it wouldn't work at all.
I can't find any issue as to why this is happening, the configuration looks normal (SSL port 465, Gmail SMTP server). I'm using Laravel 4.0.9 so I thought of upgrading to 4.1/4.2 to use the Mailgun feature (not sure if 4.0 can use Mailgun?)
Anyway, for a quick fix, I just switched to mail method for email sending. Since this works well for me, my question is that whether there is any tradeoff of using mail instead of SMTP on Laravel? The delivery seems okay as it got to my inbox, but what about the long term?
Any thoughts would be very much appreciated :)
When using the built-in mail function you don't benefit from additional features such as DKIM and the SFP configuration for your domain may not allow hosts other than your SMTP mail server to send mail for your domain, all of this makes the mail you send that way look like spam to other servers.
While you may not have issues with some providers, try to send mail to some more restrictive providers such as Outlook (ex-Hotmail); I'm pretty sure all the mail you send there will be automatically marked as spam because of the issues described above.
PHP mail may be faster since you don't have to connect to your smtp server, but it's not better. In the long run, SMTP email is the only way to guarantee that your email will arrive in the inbox of your receivers

Send emails using PHP mail function, configuration of the mail server

I am making a web application (html + php + apache + mysql) which is on a Debian server, but when I try to send any mail using the php mail function, it is not simply sent me and throws an error. I guess I should install some smtp mail service. What do you recommend that is easy for a novice user settings?
I install a library called sendmail in localhost that simulates that smpt service in WAMP server, but when I upload the code to the production server simply does not send mail.
I researched on some mail servers like postfix, but the information I get is confusing to me. I want to recommend me some effective guide, or any server that is easy to configure for a novice user in the subject.
sorry if the question is obvious, but I want effective information
For sending a mail you just simply need a smtp client that sends a mail to a destination. You don't need to install any smtp server for just sending a mail.
A smtp server is for receiving mails( and other stuff about mails).
All you need to make php sending a mail is to install a smtp client like sendmail
then edit php.ini to be like this:
sendmail_path= sendmail -t -i
EDIT: I guess debian has sendmail by default.

Sending Mail using PHP Mail function - Local mail server?

I am trying to send an e-mail from localhost but am getting the error:
Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set().
Does this mean i need to set up a local mail server?? and if so how and which one is easiest.
Thanks in advance
Paul
This is what I use, but it's for testing purposes only:
http://www.toolheap.com/test-mail-server-tool/
There's almost no configuration, and I got it to work right out of the box (on Win7) after failure with several other mail servers. It does not send the actual mail, but stores it as an .eml file. This is great for testing mailing lists for instance, where you don't really want to send the 2000 emails, but want to get a realistic result from your application.
It might look like garbage, but it's been working great for me.
Yes, it does, and if you want to send mail to an outside email address (and not a user local to the system, it is annoyingly difficult).
Most hosting companies (e.g. GoDaddy) have this setup for you, so PHP's mail() function works without you needing to do anything.
If you're configuring it on your own system, you might want to consider (a) configuring sendmail to use an alternate SMTP gateway (I frequently use Gmail) or (b) a complete alternative to sendmail (Zend Mail looks promising.)
If you are using Linux, there is usually no need to set up a a mail server,
If you are using Windows, yes, you do need to set up a mail server
If you are interested in just sending mail, you can by SMTP protocol use any SMTP server. Here is a tutorial to setting up PHP to use a remote SMTP server.
Yes, you need a mail server to be able to send mail, but even if you do, you are not going to be able to send to addresses outside of you local network as mail from your computer will be blocked by all recipients for spam reasons.
You could use the pear mail function to connect to an external smtp providor like gmail to send the mails for you. More info here and here.
smtp4dev is in my opinion the best tool for capturing local SMTP traffic on Windows.
It listens SMTP on localhost port 25 and pops up a notification every time a new mail is posted (it doesn't actually forward the mail to its recipient). You can then open the message in your favorite mail agent or save it to a file.

How to send email from local machine to gmail?

I am just learning php and it's my first question on this site. Hope, you will help me. I just want to send Email from my local machine to gmail. I have tried but didn't got any success. Please help How to do this.
my code is
form processing
return mail(
$message['to'],
join("\n", $headers))
};
?>
You will want the mail() function see: php.net/manual/en/function.mail.php
mail('kushagra#gmail.com', 'My First Email', 'The body of my email');
You will need a mail server running on your local machine such as Postfix for *nix or Pegasus for Windows.
If you do not have the ability run a mail server on your machine then you might need to use a PHP class that allows you to connect to an SMTP server such as SwiftMailer or PHPMailer.
Be aware though that a lot of ISPs will block connections on port 25 (SMTP) to protect against spamming (see my encounter of this with Optus a few years ago http://blog.simonholywell.com/post/374223466/optus-cable-port-25-smtp). If they are blocking it then you will need to use their SMTP server.
There is a tool linked in my blog post above which will allow you to determine if it is blocked or not see: http://www.zoneedit.com/smtp.html
The standard builtin function to send mail in PHP is mail():
http://php.net/mail
Unfortunately, you cannot use it with Gmail since Gmail requires two security measures that are not supported by good old mail():
Authentication
Encryption
You need to find and download a third-party library. Popular choices include PHPMailer and Swift Mailer.
If you take a look at this PHPMailer example you could use Gmail as an SMTP server to send mail to your own account - guaranteed delivery!

How to send a mail using xampp in windows XP?

I am using XAMPP for localdevelopment.And I am using the mail() function for sending the mail.
But unfortunately it wont sent the mail.I am not using any SMTP server in local host.If I need to sent mail what can I do?Thanks in advance.
You need to configure your SMTP server details in your php.ini. Alternatively, you may use a mailer library like the Swift Mailer.
As Maerlyn suggests, you can add the SMTP to your php.ini file. However thing to keep in mind is that if your SMTP server requires authentication or it requires POP before SMTP, php.ini cant help you with that. If your ISP has an SMTP server and you have configured your Outlook to use your ISP email account, it will authorize your IP (for some time) to send out emails through that SMTP server so the mail() function will work.

Categories