Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
How to send mail from localhost SMTP (using Wamp,Xampp or etc..)? PHP mail() doesn't seem to work natively.
Can anybody give the instructions?
Method 1 (Preferred) - Using hMailServer
After installation, you need the following configuration to properly send mail from wampserver:
1) When you first open hMailServer Administrator, you need to add a new domain.
2) Click on the "Add Domain ..." button at the Welcome page.
3) Under the domain text field, enter your computer's IP, in this case it should be 127.0.0.1.
4) Click on the Save button.
5) Go to Settings>Protocols>SMTP and select "Delivery of Email" tab
6) Enter "localhost" in the localhost name field.
7) Click on the Save button.
If you need to send mail using a FROM addressee of another computer, you need to allow deliveries from External to External accounts. To do that, follow these steps:
1) Go to Settings>Advanced>IP Ranges and double click on "My Computer" which should have IP address of 127.0.0.1
2) Check the Allow Deliveries from External to External accounts checkbox.
3) Save settings using Save button.
(However, Windows Live/Hotmail has denied all emails coming from dynamic IPs, which most residential computers are using. The workaround is to use Gmail account )
Note to use Gmail users :
1) Go to Settings>Protocols>SMTP and select "Delivery of Email" tab
2) Enter "smtp.gmail.com" in the Remote Host name field.
3) Enter "465" as the port number
4) Check "Server requires authentication"
5) Enter gmail address in the Username
6) Enter gmail password in the password
7) Check "Use SSL"
(Note, From field doesnt function with gmail)
*p.s. For some people it might also be needed to untick everything under require SMTP authentication in :
for local : Settings>Advanced>IP Ranges>"My Computer"
for external : Settings>Advanced>IP Ranges>"Internet"
Method 2 - Using SendMail
You can use SendMail installation.
Method 3 - Using different methods
Use any of these methods.
Here's the steps to achieve this:
Download the sendmail.zip through this link
Now, extract the folder and put it to C:/wamp/. Make sure that these four files are present: sendmail.exe, libeay32.dll, ssleay32.ddl and sendmail.ini.
Open sendmail.ini and set the configuration as follows:
smtp_server=smtp.gmail.com
smtp_port=465
smtp_ssl=ssl
default_domain=localhost
error_logfile=error.log
debug_logfile=debug.log
auth_username=[your_gmail_account_username]#gmail.com
auth_password=[your_gmail_account_password]
pop3_server=
pop3_username=
pop3_password=
force_sender=
force_recipient=
hostname=localhost
Access your email account. Click the Gear Tool > Settings > Forwarding and POP/IMAP > IMAP access. Click "Enable IMAP", then save your changes.
Run your WAMP Server. Enable ssl_module under Apache Module.
Next, enable php_openssl and php_sockets under PHP.
Open php.ini and configure it as the codes below. Basically, you just have to set the sendmail_path.
[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP =
; http://php.net/smtp-port
;smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = you#domain.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "C:\wamp\sendmail\sendmail.exe -t -i"
Restart Wamp Server
I hope this will work for you..
You can use this library to send email ,if having issue with local xampp,wamp...
class.phpmailer.php,class.smtp.php
Write this code in file where your email function calls
include('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsHTML(true);
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "your email ID";
$mail->Password = "your email password";
$fromname = "From Name in Email";
$To = trim($email,"\r\n");
$tContent = '';
$tContent .="<table width='550px' colspan='2' cellpadding='4'>
<tr><td align='center'><img src='imgpath' width='100' height='100'></td></tr>
<tr><td height='20'> </td></tr>
<tr>
<td>
<table cellspacing='1' cellpadding='1' width='100%' height='100%'>
<tr><td align='center'><h2>YOUR TEXT<h2></td></tr/>
<tr><td> </td></tr>
<tr><td align='center'>Name: ".trim(NAME,"\r\n")."</td></tr>
<tr><td align='center'>ABCD TEXT: ".$abcd."</td></tr>
<tr><td> </td></tr>
</table>
</td>
</tr>
</table>";
$mail->From = "From email";
$mail->FromName = $fromname;
$mail->Subject = "Your Details.";
$mail->Body = $tContent;
$mail->AddAddress($To);
$mail->set('X-Priority', '1'); //Priority 1 = High, 3 = Normal, 5 = low
$mail->Send();
you can directly send mail from php mail() function if you specified the smtp server and smtp port in php.ini, first ask the SMTP server credential to your ISP.
SMTP = smtp.wlink.com.np //put your ISP's smtp server
smtp_port = 25 // your ISP's smtp port.
then just restart the apache server and it will start working. ENjoy ...
I prefer using PHPMailer script to send emails from localhost as it lets me use my Gmail account as SMTP. You can find the PHPMailer from http://phpmailer.worxware.com/ . Help regarding how to use gmail as SMTP or any other SMTP can be found at http://www.mittalpatel.co.in/php_send_mail_from_localhost_using_gmail_smtp . Hope this helps!
If any one of you are getting error like following after following answer given by Afwe Wef
Warning: mail() [<a href='function.mail'>function.mail</a>]: SMTP server response:
550 The address is not valid. in c:\wamp\www\email.php
Go to php.ini
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = valideaccount#gmail.com
Enter valideaccount#gmail.com as your email id which you used to configure the hMailserver in front of sendmail_from .
your problem will be solved.
Tested on Wamp server2.2(Apache 2.2.22, php 5.3.13) on windows 8
If you are also getting following error
"APPLICATION" 6364 "2014-03-24 13:13:33.979" "SMTPDeliverer - Message 2: Relaying to host smtp.gmail.com."
"APPLICATION" 6364 "2014-03-24 13:13:34.415" "SMTPDeliverer - Message 2: Message could not be delivered. Scheduling it for later delivery in 60 minutes."
"APPLICATION" 6364 "2014-03-24 13:13:34.430" "SMTPDeliverer - Message 2: Message delivery thread completed."
You might have forgot to change the port from 25 to 465
Related
How can I check failed mails. Swiftmailer is returning true even if i supply invalid email address. I need to log send and failed mails into database
$message = Yii::$app->mailer->compose();
$message->attach($protocal.$_SERVER['SERVER_NAME'].$payslip);
$message->setTo("tft#sjkdsjk.dfdh");
$message->setFrom("hr#gmail.com");
$message->setSubject($vStaffName." ".$vPeriodName. " Payslip");
$message->setTextBody("Find attached copy of your payslip. To open this document use your ID number as password");
$send = $message->send();
var_dump($send);die(); //returns true always
I would expect true or false
You should check with SMTP.
That means you have to connect to that email's SMTP server.
After connecting to the SMTP server you should send these commands:
HELO somehostname.com
MAIL FROM: <no-reply#gmail.com>
RCPT TO: <emailtovalidate#domain.com>
If you get " Relay access denied" that means this email is Invalid.
There is a simple PHP class. You can use it:
http://www.phpclasses.org/package/6650-PHP-Check-if-an-e-mail-is-valid-using-SMTP.html
I can send emails from a linux server by typing the following on the console, without any issues:
mail -s "Test Subject" testemail#gmail.com < /dev/null
I try to send it via a Java app, using javax.mail via:
public void sendMail() throws MessagingException
{
final Properties p = new Properties();
p.put("mail.smtp.host", "localhost");
final Message msg = new MimeMessage(Session.getDefaultInstance(p));
msg.setFrom(new InternetAddress(from));
msg.addRecipient(RecipientType.TO, new InternetAddress(to));
msg.setSubject("Test");
msg.setText(body);
Transport.send(msg);
}
but I get a
Causing: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 25; timeout -1
error, is this due cause I need to replace
p.put("mail.smtp.host", "localhost");
with my server's address? if yes, where can I find what I should put there?
Thanks!
Do you have a mail server running on your local machine?
Have you configured sendmail to route messages to your mail server?
If you run "mail -v ..." it should tell you what the mail command is doing to send your message.
But yes, most likely, you want to configure JavaMail to connect directly to your mail server, which is probably not running on your local machine. You'll find more help in the JavaMail FAQ.
I have two SMTP servers listening on ports 2525 and 2526.
But I have only 1 public IP address.
I'd like to use postfix (already installed on my server) to receive emails only for domain xxx.company.com and domain yyy.company.com, and redirect those emails to server 1 (port 2525) for domain xxx.company.com and server 2 (port 2526) for domain yyy.company.com.
Postfix will not be used to send emails. Just receive.
I tried several postfix configurations but I haven't figured out how to do this properly.
For now, I end up with this:
In main.cf:
mydomain = company.com
mydestination = xxx.company.com, yyy.company.com
relay_domains = xxx.company.com, yyy.company.com
transport_maps = hash:/etc/postfix/transport
local_recipient_maps =
unknown_local_recipient_reject_code = 550
In transport.cf:
*xxx.company.com 2525:[localhost]
*yyy.company.com 2526:[localhost]
In master.cf, the following line has been uncommented:
local unix - n n - - local
But I still have an "unknown user" error if my maillog file.
I would like to be more accurate for local_recipients so I don't let the entire world enter my postfix.
Does anyone have an out-of-the-box example of such kind of configuration ?
Thanks,
Jeremy B.
Your main.cf should be
#/etc/postfix/main.cf
mydomain = company.com
mydestination = xxx.company.com, yyy.company.com
relay_domains =
transport_maps = hash:/etc/postfix/transport
local_recipient_maps = hash:/etc/postfix/local_users
also add the following files
#/etc/postfix/local_users
# Here ACCEPT can be anything,postfix doesn't use it.
someuser#xxx.company.com ACCEPT
someuser#yyy.company.com ACCEPT
#/etc/postfix/transport
xxx.company.com smtp:[localhost]:2525
yyy.company.com smtp:[localhost]:2526
# modify localhost, if the server1 and server2 is not on localhost
Hope that helps.
I had to implement Password Reset policy....For which I had OpenSSO deployed on Glassfish server and OpenDS as the Data Store...I followed Indira's blog...
Password Reset With OpenDS
And executed all commands....Since I did not configure SMTP, when I try to Reset the Password of a particular User (Note: I hav specified a Gmail ID as the email Address of that user) after answering the Question, I get confirmation saying
"Your password has been reset but we are unable to send it to you. Contact your administrator."
How do I configure SMTP in OpenSSO and OpenDS?
OpenDS (and OpenDJ, the continuing open source project) has some global properties to point to the SMTP server.
Note that it doesn't support authentication at this point.
$ dsconfig set-global-configuration-prop --port 4444 --hostname hostname --bindDN "cn=Directory Manager" --bindPassword password --set smtp-server:smtp.example.com --trustAll --no-prompt
Kind regards,
Ludovic
I just had this problem, so for the record I think it's probably because you need to replace <Password-Administrator> in the WEB-INF/classes/amPasswordResetModuleMsgs*.properties files with a real email address.
I found that my Authentication debug log file had this error in it:
ERROR: Could not send email to user [Ljava.lang.String;#30720e48
com.sun.mail.smtp.SMTPSendFailedException: 553 5.5.4 <Password-Administrator>... Domain name required for sender address Password-Administrator
;
nested exception is:
com.sun.mail.smtp.SMTPSenderFailedException: 553 5.5.4 <Password-Administrator>... Domain name required for sender address Password-Administrator
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2057)
I found the solution on the OpenAM mailing list originally: http://lists.forgerock.org/pipermail/openam/2012-April/005912.html
I used this sed command to do update all the files at once:
sed -i -e 's/\<Password-Administrator\>/user#address\.com\.au/g' amPasswordResetModuleMsgs*.properties
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I am using SMTP to send emails by PHP.
My client has a shared hosting.
I created an email account there.
There is no information available about what will be the SMTP server for this account.
I have tried: smtp.domainname.com
But it's not able to connect.
How can I figure out my SMTP server host? any idea?
this really is a question for Serverfault.
Windows:
Open up a command prompt (CMD.exe)
Type nslookup and hit enter
Type set type=MX and hit enter
Type the domain name and hit enter, for example: google.com
The results will be a list of host names that are set up for SMTP
Linux:
Open a command prompt
Type dig domain.name MX and hit enter where domain.name is the domain you are trying to find out the smtp server for.
If you do not get any answers back from your dns server, there is a good chance that there isn't any SMTP Servers set up for that domain. If this is the case, do like other's have suggested and call the hosting companies tech support.
generally smtp servers name are smtp.yourdomain.com or mail.yourdomain.com
open command prompt try to run following two commands
>ping smtp.yourdomain.com
>ping mail.yourdomain.com
you will most probably get response from any one from the above two commands.and that will be your smtp server
If this doesn't work open your cpanel --> go to your mailing accounts -- > click on configure mail account -- > there somewhere in the page you will get the information about your smtp server
it will be written like this way may be :
Incoming Server: mail.yourdomain.com
IMAP Port: ---
POP3 Port: ---
Outgoing Server: mail.yourdomain.com
SMTP Port: ---
You could send yourself an email an look in the email header (In Outlook: Open the mail, View->Options, there is 'Internet headers)
You can use the dig/host command to look up the MX records to see which mail server is handling mails for this domain.
On Linux you can do it as following for example:
$ host google.com
google.com has address 74.125.127.100
google.com has address 74.125.67.100
google.com has address 74.125.45.100
google.com mail is handled by 10 google.com.s9a2.psmtp.com.
google.com mail is handled by 10 smtp2.google.com.
google.com mail is handled by 10 google.com.s9a1.psmtp.com.
google.com mail is handled by 100 google.com.s9b2.psmtp.com.
google.com mail is handled by 10 smtp1.google.com.
google.com mail is handled by 100 google.com.s9b1.psmtp.com.
(as you can see, google has quite a lot of mail servers)
If you are working with windows, you might use nslookup (?) or try some web tool (e.g. that one) to display the same information.
Although that will only tell you the mail server for that domain. All other settings which are required can't be gathered that way. You might have to ask the provider.
To automate the answer of #Jordan S. Jones at WIN/DOS command-line,
Put this in a batch file named: getmns.bat (get mail name server):
#echo off
if #%1==# goto USAGE
echo set type=MX>mnscmd.txt
echo %1>>mnscmd.txt
echo exit>>mnscmd.txt
nslookup<mnscmd.txt>mnsresult.txt
type mnsresult.txt
del mnsresult.txt
goto END
:USAGE
echo usage:
echo %0 domainname.ext
:END
echo.
For example:
getmns google.com
output:
google.com MX preference = 20, mail exchanger = alt1.aspmx.l.google.com
google.com MX preference = 10, mail exchanger = aspmx.l.google.com
google.com MX preference = 50, mail exchanger = alt4.aspmx.l.google.com
google.com MX preference = 40, mail exchanger = alt3.aspmx.l.google.com
google.com MX preference = 30, mail exchanger = alt2.aspmx.l.google.com
alt4.aspmx.l.google.com internet address = 74.125.25.27
alt3.aspmx.l.google.com internet address = 173.194.72.27
aspmx.l.google.com internet address = 173.194.65.27
alt1.aspmx.l.google.com internet address = 74.125.200.27
alt2.aspmx.l.google.com internet address = 64.233.187.27
For example to pipe the result again into a file do:
getmns google.com > google.mns.txt
:-D
Quick example:
On Ubuntu, if you are interested, for instance, in Gmail then open the Terminal and type:
nslookup -q=mx gmail.com