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

Explode a string after 5 spaces and 2 new lines in a string in PHP
How to create a button that links to different URL using if-else statement
How to display category's items?
Distinguish tr in dynamic table form for serializing jQuery
phpMyAdmin doesn't show new databases
decode base64 and pass to zip file
Passing POST data from ionic framework to CodeIgniter Rest API
Mail function can be misused
PHP - Is it possible to upload a zip file to the database after the zip is created in php?
Path to mpdf/jpgraph library in PHPExcel example on Windows
Convert row from database into image
How To Use Google Sheets API v4 To Create New Sheet or Tab in Spreadsheet with PHP
PHP $_POST arrays with multiple rows
Displaying nothing when I am trying to scrape data using simple html dom parser
PHP inserting late through time blocks
YII Server Move. Internal Server Error. CDbException

Categories

HOME
gaming
message-queue
code-formatting
cypher
jint
firebase-database
onvif
selection
port
driver
spring-amqp
django-rq
heap-dump
vmware-workstation
pinterest
jqxgrid
cocos2d-android
word2vec
spring-shell
android-custom-view
gollum-wiki
qa
react-dnd
morris.js
android-service
react-bootstrap-table
bobo-browse.net
bonita
substance
infopath2010
nsmutablearray
autoencoder
oauth2
suds
python-jira
angular-datatables
code-push
adblock
autorelease
freshdesk
nivo-slider
network-protocols
gmaps.js
sidewaffle
mifos
gulp-uglify
trust
deeplink
perceptron
variable-length-array
lowercase
extend
hmisc
360-degrees
supersocket.net
vdm-sl
explain
componentart
phpredis
deque
prism-4
camus
utf8-decode
jquery-mobile-flipswitch
zend-search-lucene
sql-function
bittorrent-sync
property-injection
jomsocial
lync-2010
meteorite
apache-shindig
grails-2.3
insertonsubmit
blobstorage
spiral
itunes-sdk
clearinterval
flymake
autosize
nsfont
background-repeat
django-apps
database-deadlocks
nsconnection
regression-testing
git-log
eaccelerator
mygeneration
pinax
j2mepolish
firephp
service-factory
synthesizer

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