i am doing one project. In that project i want to send mail to my customers in php.
presently i am using the sendmailer.php package to sent mail.
Using this package i am sending the mail through my gmail account(i.e, SMTP Protocol).it takes 20 sec-1 min.
here my doubt is...
is it possible to send mails to customers with out using smtp protocol..
i know there is a function called mail()..
but my doubt is..!! is it send my mail to customers..?
please clarify my doubt..
i am stuck here..!!
No, It's not possible without a SMTP.
You have to define your own SMTP server settings that normally your host provides, in the PHP ini file for example, when you use the normal mail() function.
You can change the settings like this:
ini_set("SMTP","smtp.example.com" );
ini_set('sendmail_from', 'user#example.com');
Related
I'm created a website with PHP on a Linux web hosting package. Normally I will get emails sent by its contact form that produced by PHP Mail() function. But this time, it is a strange case for me.
My customer company has a mail server. If I send an email via my personal email on Gmail, they will get it on their mail server. But when I send emails via contact form, emails go to webmail on website hosting package.
I've removed all email accounts on this host, also I removed DNS MX record from it, but still I can not receive emails sent by contact form on the company mail server accounts.
How can I solve this problem?
As it seems from your question the webshoting provider is also your email hosting provider. The way you explained the problem leads me to the conclusion that your PHP script uses the mail() function which will internally call the MTA (like sendmail) to send the email.
Now what seems to happen here is that PHP is sending the mail through mail() function which is passing it on to the local MTA (like sendmail) which is checking the local configuration. In the local config it seems to find the recipient domain as a local domain and deliver the mail locally to the user. In this case the email is not even leaving the webhoster's server.
As this is not what you expect, you have 2 possibilities if you do not have influence to the MTA's configuration (what i think you dont have).
I would propose (if possible) to not use the mail() function. There are ready to use SMTP classes which will connect to a SMTP server of your coice to send the email to. In that way you can avoid this problem. You should find something in the PHP Classes Repository.
Send the email to a different domain if possible. That way the MTA has to check DNS and send the email to another SMTP server for delivery.
The first thing to establish is how you are sending emails (sendmail or SMTP). Then, whether your emails are a) not sent at all or b) getting rejected by the destination mail server.
I'd check all available logs (source and destination mail servers and daemons). See if mail() itself is erroring. Try using sendmail/smtp directly.
If its the destination server rejecting the mail based on its spam score, try setting SPF records to enable the web server to send mail legally.
If your email function "mail($to,$subject,$message)" is not working then you need to check the server configuration. Now it is enable or not .
For more details, see here : https://wycks.wordpress.com/2013/10/09/when-phps-mail-function-doesnt-work/
Is there anyway to send email via gmail (or other free provider) in php.
But I want to use php built in mail() function.
This solution is only for dev and staging.
Thanks
You can, using PHPMailer. And also check here to know details you should provide in your script so that you be able to send using Gmail SMTP.
Source
Plenty of walk-throughs and pre-made scripts/classes if you just used google. Unless you want to make yours from scratch.
If you don't want to use libraries but still want to send email via gmail, you have to setup SMTP server which sends email via Gmail. One very easy alternative is SSMTP. Setting up SSMTP is very easy.
http://tombuntu.com/index.php/2008/10/21/sending-email-from-your-system-with-ssmtp/
Hope it helps.
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.
I have used php mail function for sending mail to local mail id's and external mail id's.
using this mail function I am able to send mail to my local mail id's but the mail function is not sending mail to external mail id's. like ss#gmail.com
I have used the following methods to set the SMTP server address.
ini_set("SMTP","net4india.com");
ini_set("sendmail_from","sugumar#csoft.co.in");
and I added with header also
$headers .= "SMTP-Hott:
net4india.com";
but the mail is not going to gmail.
where I need to configure the SMTP server name in my program to send the mail to gmail,yahoo ,hotmail,etc.,?
I have found that using the Pear libraries: Net_SMTP, Mail that you can get better error messages and offers a wider range of options:
http://pear.php.net/package/Net_SMTP
http://pear.php.net/package/Mail
You may want to try using those libraries rather than the built in mail function for php: Demo on how to use Pear Mailer Class
My first recommendation is to use PHPMailer to send email in PHP: http://phpmailer.worxware.com/
Aside from that, I know that google will check SPF DNS records to validate your from address. Here is a wizard that'll help you create an SPF record for your domain: http://old.openspf.org/wizard.html?mydomain=example.com
The MX record for csoft.co.in (64.187.109.136) is gw-mail7.myhsphere.biz (204.10.107.116). So net4india.com (202.71.130.4) would probably reject your e-mail since it doesn't know who you are. In these days of spam you cannot connect to a random mail server and have your e-mail delivered to someone else.
Whatever, net4india.com doesn't even seem to host a SMTP server at all.
To sum up: learn from whoever provides you with mail service for your "#csoft.co.in" account what the SMTP settings are. If you have to provide a password, you cannot use the built-in mail() function at all.
I have to send email from my gmail account using php mail() function. I have read the phpmailer but I don't want to include any external apis. Please suggest.
Thanks in advance.
You cannot use mail() to send email with your Gmail account, you'll have to use something that talks to Gmail SMTP server directly. So you're stuck with writing your own or using one of the availiable libraries, the most commonly known are:
Swift Mailer
PHP Mailer
Zend Mail
Assuming mail() works on your server, just:
<?PHP
mail($to,$subj,$body,"From: yourname#gmail.com\r\n");
should do it.
The reason this works is that the "From" address on an email is really very much like the return address on a snail-mail envelope. I can write a letter and mail it from my home, with a return address for my office.