I am really confused on where to start with sending emails. I have search the web but the amount of content available for different packages and softwares has really confused me. I was wondering if anyone here had a simple or knows of a simple tutorial of how i can send an email using xampp.
Im new to using local host and so far have only used MySQL and Apache from xampp to load and view my php files for an application.
I would really appreciate it if anyone could help me start setting up XAMPP to send emails when i use the php.
Some sites suggest a separate server is needed for emails such as PHPMailer while others suggest a few config changes need making like changing in the php.ini files which I'm very cautious to change incase my whole xampp crashes!
is this link any good? http://www.websnippetz.com/2013/01/send-email-from-xampp-localhost.html
Many are using SendMail package with XAMPP but i can't find a download for that.
anyone tried anything which worked for them?
please help a very confused developer guys!
Some sites suggest a separate server is needed for emails such as PHPMailer while others suggest a few config changes need making like changing in the php.ini files which I'm very cautious to change incase my whole xampp crashes!
PHPMailer is not a server it is a library. People often recommend using a Mail library because the built mail functions are very low level and hard to work with. Because they are modeled after using sendmail from the commandline.
If you want to send via SMTP, use attachments, or other things it can be difficult or impossible to do with mail() directly.
Personally I recommend using SwiftMail over PHP mailer. IMO, it's more modern, easier to use, and has a better API, and depending on which PHP F/OSS projects you are used to using or contributing to its more common and the standard.
Overall there are 2 parts to sending mail from PHP:
Setup of the actual mail server on a system (local or otherwise)
The configuration of PHP to use that mail server.
To setup the mail function you need to install and configure a mail server locally in order to fulfill item (1). This should already be included and set up on OSX. So to fulfill item (2) you need to configure PHP via the INI to use that mail server by changing the sendmail_path.
Now if you want to use a library, which I recommend you need to get that source into your project and then use it appropriately. For the example we will use SwiftMailer, with SMTP transport via a gmail account:
require_once 'PATH/TO/swift_required.php';
// Create the Transport
$transport = Swift_SmtpTransport::newInstance('smtp.googlemail.com', 465, 'ssl')
->setUsername('user#gmail.com')
->setPassword('secret');
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance('My SMTP Message')
->setFrom(array('john#doe.com' => 'John Doe'))
->setTo(array('receipient#domain.com', 'other#domain.com' => 'A name'))
->setBody('Plain Text Message Body');
$mailer->send($message);
To send emails from your localhost your need an Email-Server like postfix or Exim or you send your E-Mails over SMTP what is described on that site from your link.
The easiest way is to use an abstraction layer like Swift Mailer
http://swiftmailer.org/docs/sending.html
Here you have a lot of possibilities to send E-Mails. Another solution is to install a local Mailserver and fetch all sending E-Mails. In MAMP Pro for example you have an integrated Mailserver.
http://blog-en.mamp.info/2009/09/how-to-sending-emails-with-mamp-pro.html
Related
I can send emails in PHP because I edited the php.ini file the the XAMPP directory. Then I uploaded my PHP file in a free domain, I can't send the email anymore because the php.ini file is obviously for xampp only. How can I send an email on an online domain?
you can use 3rd party services like twilio and use their API to send the mails , you can even send whatsapp messages through that
You can also configure a email sending service for apps like Sendgrid or equivalent in order to be able to send out emails.
Most hosting providers block SMTP port 21 to avoid issues with spammers. The right way to do this is by using such a service I have suggested.
If you want to send mail with php, online, via Gmail...
Setup your project to use Composer.
https://getcomposer.org/
Add phpmailer to your project through Composer
https://github.com/PHPMailer/PHPMailer
composer require phpmailer/phpmailer
Configure your Gmail to be able to use smtp from php
Little tutorial regarding all described
https://netcorecloud.com/tutorials/send-an-email-via-gmail-smtp-server-using-php/
Following all the steps, you'll be able to work/use your code in localhost with xampp or online, without changing anything
I have a server with a webapp and a mail server (who use sendmail to route mails).
We need to migrate the webapp to an auto-scaling schema, so, I can't have the mail server in there, so, I'm thinking on leaving the mail server right where it is now.
So, to send mails I have different alternatives, I don't want to migrate to an external provider, the costs are to high (like 100 usd/m for mails + dedicated IP).
I'm looking for a way to connect my webapp PHP mail sending classes to this external server with sendmail.
Is there any way I can achieve this without creating my own API to send mails?
On Windows-servers you can change SMTP in php.ini.
Also, you can try to setup relayhost through Postfix (example here), but it seems like a simple API is the easiest and right solution :)
I'm switching a web app over to AmazonSES. We're using PHP 5.3, PHPMailer, and we tried using the AmazonSES pear package but for some reason it was unbelievably slow on the live server. We switched to the Amazon perl script thats use sendmail instead and it's much faster.
However, the Undisclosed Recipients feature (built in to AmazonSES pear code) was no longer available. No matter what I do, the only thing I can get working it by addressing an email as "To: Undisclosed Recipients <workingadd#domain.com>"
The problem is that the working address HAS to be there: php's mail() func require it, phpmailer requires it. The problem is, using noreply# fails, but workingaddress# works. While the recipient list is protected, we end up getting all the emails at that address.
However, the Amazon code managed to send mails without a primary address. I can't find anything in their code that suggests the answer, nor on the net.
Please help!
Oh, You want to send mail, Please careful that MTAs don't you as SPAM, if you want to know all of its rules please read all of rules of SpamHaus
Set up an interim relay server with postfix or sendmail. Have your application send emails to that server. Have that server connect to amazon and send the mail to it. Let it handle the authentication, etc. It works extremely well.
--David
Hi I am running MAMP on my mac to locally host a website. I want to send an email using php scripts. The stuff i looked online tells me about php scripts for emails but i am unable to send emails. I am guessing this has to do with MAMP settings or maybe i have to make changes to php.ini file but i cant find information regarding that. Can i send emails to my clients using my gmail address running php scripts. I am creating a signup page where once you signup successfully, the site sents you a welcome email. Can some body please guide me how to do this. I have used code from here:
http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm
but this doesnt work.
i have used following settings:
$host = "ssl://smtp.gmail.com";
$port = "465";
MAMP is just Apache, MySQL and PHP and doesn't include a mail server. You could use postfix or, as you said, an external SMTP server.
If using Gmail make sure your account is setup to allow SMTP connections (it's off by default). This can be found somewhere in Settings in the web client. I'd recommend you test it with Mail or another mail client on your local machine to make sure Gmail is working as expected.
Finally (once the above is set up) SwiftMailer or PHPMailer are good mail libraries which can connect to remote SMTP servers. It'll save you a lot of headaches writing your own code, especially when it comes to file attachments and such.
Hi I have been reading alot of articles adoring the PEAR mail package and it seems like PEAR is something I need to try out.
I am interested in setting up a full mail server, similar to a conventional SMTP mail service; which incorporates mail queuing, resending with a backend database etc. My impression is that PEAR can do this but can its service be used with mail clients like outlook to send mail, just as how any any smtp server daemon can where one would enter a portnumber, server name and/or security protocol?
Thanks
No, PEAR isn't going to magically solve these problems for you.
PEAR is a collection of PHP classes that are meant to solve common problems faced by PHP users. The Mail packages offer code for interacting with different parts Email systems. They do not contain code for creating email systems from scratch.
For example, form the Mail_Queue documentation
The Mail_Queue class puts mails in a temporary container, waiting to be fed to the MTA (Mail >Transport Agent), and sends them later (e.g. a certain amount of mails every few minutes) by >crontab or in other way.
The MTA in this case in sendmail, postfix, etc.
Another example, from the Mail_Mbox documentation
It can split messages inside a Mbox, return the number of messages, return,
update or remove an specific message or add a message on the Mbox
Incorrect use of "an" aside, you are using this to read existing MBOX files, and not caring how they got there.
The Mail package is about interacting with existing mail systems, NOT creating replacements. You'll still need to understand how all those email systems work to create a "full mail server, similar to a conventional SMTP mail service". If you're doing this because you want to learn how email systems work, have at it. If you're doing this because you thing this will give your business some leg up in the email game, I laugh and say "good luck with that"
PEAR is a repository for lots of libraries. Some of them deal with mailing.
PEAR's Mail class is designed for sending mail only. It is not designed as an implementation of an SMTP server.
Pear Mail is an SMTP sender aka client, not an SMTP server. Although it's entirely possible to write server (any kind of server) in php that doesn't mean that writing an SMTP server yourself is necessarily a good idea as it requires quite some expertise to do it right (spam anyone?). If you want to see an SMTP server implemented in a scripting language, go have a look at Lamson, written in Python by Zed Shaw.
And while you're there, do read the About page. This quote says it all
However, as great as Lamson is for
processing email intelligently, it
isn’t the best solution for delivering
mail. There is 30+ years of SMTP lore
and myth stored in the code of mail
servers such as Postfix and Exim that
would take years to replicate and make
efficient. Being a practical project,
Lamson defers to much more capable
SMTP servers for the grunt work of
getting the mail to the final
recipient.
It seems to me that PEAR's MailQueue package may address your needs.