Im trying to use PHP mail on my local computer, but its just not working. I am using the standard script from the php website:
PHP error I'm getting
SMTP server response: 550 Error sending message: Error: FROM address is invalid
actual PHP
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
i downloaded a local mail server, argosoft. it says the service URL is http://services.argosoft.com/RelayService/Service.asmx . I assume this is what i put in php.ini.
php ini.
For Win32 only.
SMTP = services.argosoft.com/RelayService/Service.asmx
smtp_port = 25
I have had this error before, and I believe all you have to do is change the email webmaster#example.com to a real email. Make sure you send it to a real email as well.
Replace #example.com with real email addresses.
and in PHP.ini set
SMTP = localhost
Apparently, a number of mail systems have trouble with the carriage return \r. You might want to modify your $header to use only the new line character \n. See if that works.
Also, you might want to try using the full From header:
From: Some Name Here <real_email#notAnExample.com>
Related
Currently trying to do the following but was unable to do so:
Set up 2 accounts on Mercury using XAMPP.
Install Thunderbird and add both accounts as POP3 accounts.
Sending using the Thunderbird client from one user to another works fine.
However, using testsend.php does not work for me and produces an error:
Warning: mail(): SMTP server response: 553 We do not relay non-local mail, sorry. in C:\xampp\htdocs\email\testsend.php on line 17
testsend.php
<!DOCTYPE html>
<html>
<body>
<h1>Hello mail</h1>
<p>My first m</p>
<?php
$to = 'user#local';
$subject = 'Email';
$message = 'Test';
$headers = 'From: userb#local' . "\r\n" .
'Reply-To: userb#local' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers, '-user#localhost');
echo 'sent successfully!';
?>
</body>
</html>
I've received the warning, and after some googling, I did this:
Unticking the box.
Afterward, I rerun the file; this time, there were no warnings or errors. However, no emails appeared in my Thunderbird client for both users.
Any possible solutions to this? Thank you!
I am trying to use Yahoo SMTP server to send emails from a web site, located on local Windows server and based on Xampp.
As a result, this is what I have in my sendmail settings :
smtp_server=smtp.mail.yahoo.com
smtp_port=465
smtp_ssl=auto
auth_username=box1#yahoo.com
auth_password=pswd1
Then in PHP :
mail ('box1#yahoo.com', 'Static Mail 1', 'Static Message');
mail ('box2#yahoo.com', 'Static Mail 2', 'Static Message');
So, I am trying to send email from one Yahoo account to another but it does not work.
I tried to send emails with GMail SMTP and it works fine but when I try to do this through Yahoo SMTP I always get an error :
From address not verified - see http://help.yahoo.com/l/us/yahoo/mail/original/manage/sendfrom-07.html
As far as I know, this is a common problem when Yahoo does not allow to send emails on behalf of it, but in my case I am sending messages only between Yahoo accounts, what am I doing wrong?
Issue for cross server requests is described here but in some reason I am experiencing it even when I use only Yahoo accounts too.
Seems like the error is pretty self explanatory, add the fourth paramater for the mail function, something like this:
<?php
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
I working on a project in which i need to develop a functionality to send multiple emails to client with one click and i am adding customer id in one text box separating them with comma.
Please tell me how to do this problematically. Your advice
<?php
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
if you want to send the user as in db jus replace the $to address from db and place these code in loop.
php.net's mail function page explains this well
to be fair we all had to start somewhere. The problem with using "vanilla PHP mail" is that it is almost always used when people send mail as spam. So for 10 years mail servers haven't liked it. There are ways round it but to be brief:
To send Email via a webpage you "should"
have your mail server resolve RDNS
try to avoid cheap/free web hotels as mailserver hosts
use PHP PEAR MAIL (this is tricky/odd to install)
properly apply the correct headers for the mail in PEAR
Check below link may be help you.
http://www.quackit.com/php/tutorial/php_mail.cfm
this may be a noobish question. I'd like to know if I can send emails from the server that say, domain1.com is associated with, as coming from domain2.com and also having the origin show as coming from domain2.com?
The reason I'd like to do this, is because I have an application I'm developing and would like to send emails from the domain, for example - maildomain.com instead of coming from domain.com
Emails are being sent with php's mail function.
Yes, you can:
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example-two.com' . "\r\n" .
'Reply-To: webmaster#example-two.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
You should set up some things, so the receiver doesn't mark it as spam though:
Set up DNS MX records with low priority for the receiving domain, pointing to sending server
Setup correct reverse DNS entries for sending server
..
The "From" address in an email is entirely arbitrary. As long as you have permission to submit mail to a server's queue, you can put any From address in it that you want. president#whitehouse.gov, julian#wikileaks.org, etc.
To do this with PHP's mail() function, use *$additional_headers*. For example:
$to = "whoever#example.com";
$subject = "This is an example!";
$message = "Hello,\n\nThis is message body.\n\nIsn't that nice?\n\n";
$headers = "From: El Presidente <president#whitehouse.gov>\r\n"
. "X-foo: bar\r\n";
$result = mail($to, $subject, $message, $headers);
Possible? Yes is sure is. See the below example from PHP.net. However, I'm going to put a little piece of fine print here, as I think you might run into some trouble, and I want to make it easier for you in the future. ;) Your current webhost may block this, I've never seen it, but I've heard it can happen. Also, there is a thing called SPF, or Sender Policy Framework, that is a DNS record that you can set to determine what servers can send on your behalf. Many servers that could receive your mail, and especially GMail check for valid SPF. All you have to do is add a TXT record on your name server for domain.com. It should look something like this: v=spf1 mx a:maildomain.com -all. This says any records that have an MX record set up, and the IPs that are resolved from maildomain.com are valid 'non-spam'. Also, you will to fail any other mail origin.
<?php
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
If the mail server is an open mail relay then yes, you can send from a different domain. It is of course seen as a vulnerability as spammers can use it to send out junk mail. The configuration of the mail server to get this functionality depends on its platform but you can usually test a server's ability to freely relay messages by telneting to the server on port 25 and doing an ehlo test.
Whenever I send an email to my clients, their inbox shows the email details of my server that is hosting my website, instead of the email I mention in the from variable. something like this
From John Smith username704#sadalsuud.hostingService.com
What I want is this
From accounts#myWebsite.com
Help will be appreiated. I am clueless as to whether it is a question more suitable for mentioning in Serverfault. If so, then let me know.
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
What Narek says sometimes works, but kind of depends of the settings. I had a simular problem in the past using mail() and whatever i tried, i sometimes just got the hostname. It appeared to be a server(settings) issue.
What did help me, was using Swiftmailer over SMTP ( http://swiftmailer.org/ ) instead. You should give it a try, it's a very nice script.