php


Sending mail in PHP [closed]


I am trying to send mail using PHP mail() function. I have install postfix, modified all of the required files as suggested by the Ubuntu help docs.
I also changed my php.ini file to set the path of the sendmail_path to sendmail_path = "/usr/sbin/sendmail -t -i" but still I cannot send mail to my hotmail account or yahoo or gmail.
Edit:
Stop down voting me ; even I do not know my problem . All I realized so far is that my ISP is blocking every port except 80 . If any one can help me mitigate that problem , it will be my pleasure .
When you configure Postfix you dont need sendmail which is also an MTA like Postfix.
So sendmail_path = "/usr/sbin/sendmail -t -i" is not used by php.
You have to connect to your Postfix server (which is listening in localhost:25) by php to send mail.
Here is an example modified based on this answer,
<?php
require_once "Mail.php";
$from = "<from.gmail.com>";
$to = "<to.yahoo.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "localhost";
$port = "25";
$username = "<myaccount.gmail.com>";
$password = "password";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>
Note that Mail is a pear package.

Related Links

Remove individual theme option fields from Wordpress theme
Laravel: PDO Exception, cannot find driver even though the driver is installed and tested [duplicate]
How to arrange the_content() in Wordpress post page?
Remove tags from product page in Woocommerce
import sql file in php
simple form using bootstrap and php script completely not working
query false but performs query
How to stop loop redirection in ZF2 Module
Extending controller class in the same file
Cron tab with php parameters with unix variable [duplicate]
What Happens When We Instantiate a PHP Class?
Get data from child product
Use woocommerce with calculated quot from front end
How to login to Amazon SellerCentral using Goutte
How to create VoIP Notification provisioning profile?
Unable to set html table height and width with php variabile

Categories

HOME
keyboard
foaf
message-queue
stacktrace.js
whmcs
tcp
elisp
openflow
share
static-analysis
azure-logic-apps
gtk
lapack
alljoyn
rangy
spring-amqp
webstore
scheduled-tasks
parceler
amazon-mws
opam
multi-upload
ini
react-dnd
gravity-forms-plugin
annotation-processing
region
es6-modules
knights-tour
microsoft-certifications
shapeless
kendo-listview
char-pointer
transform
orchardcms-1.8
busboy
djcelery
linq.js
export-to-pdf
grunt-contrib-watch
icepdf
cloudera-sentry
fluid-mac-app-engine
morphline
ipp-protocol
.net-micro-framework
password-hash
openstack-glance
gestures
algebra
asp.net-web-api-routing
mobile-angular-ui
apache-modules
instafeedjs
portal
openquery
visual-studio-monaco
pyaudio
unsigned
adp
as3-api
wikimedia-commons
ioexception
godeps
variable-length-array
ruby-on-rails-4.1
replicaset
ampersand
actionpack
dbmigrate
wicked-gem
nanomsg
cout
nesper
inputbox
berkeley-db-xml
mobile-country-code
.htpasswd
incognito-mode
meteor-collections
radius-protocol
visual-c++-2005
ggts
unrealscript
disjoint-union
hints
ax
jquery-lazyload
sly-scroller
oscilloscope
contextswitchdeadlock
nsmutablestring
page-curl
upshot
bll
hungarian-notation
outlook-2007-addin
resharper-5.0
tacit-programming
iphone-sdk-3.1.3
account-management

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App