Cannot send emails via Yahoo SMTP - php

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);
?>

Related

Why don't I see any mails in sent mail or the recipient doesn't receive any mail that is sent using sendmail in php? [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
php code:
<?php
$to = 'vickee#hotmail.com';
$subject = 'Testing sendmail.exe';
$message = 'Hi, you just received an email using sendmail!';
$headers = 'From: vignesh#gmail.com' . "\r\n" .
'Reply-To: vignesh#gmail.com' . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($to, $subject, $message, $headers))
echo "Email sent";
else
echo "Email sending failed";
?>
I have enabled second step verification in gmail. Is the prob due to that and I get "Email sent" when I run the php code. But there are no mails in the sent or recipient's inbox or junk folder. Are there any alternative methods? If so, please comment link for step by step procedure to send emails using the service.
EDIT:
I've setup the mailing part as instructed in http://arpanthakrar.blogspot.in/2013/06/send-email-from-localhostwamp-server.html
Please do let me know if there are anyother methods or changes to be made in this method.
Let me clearify a bit the "sending" of E-Mail:
$to = 'vickee#hotmail.com';
...
$headers = 'From: vignesh#gmail.com' . "\r\n" .
that means: send an email to "vickee, coming from vignesh"
That does not mean: "Use gmail to send an email to vickee"
Instead, PHP is using the local mailer to transport the mail. The mail is passed by your box, your providers MTA etc. to vickee's inbox at hotmail.
Your gmail account is not involved in to this. So looking in to the "sent" folder of your gmail account doesn't make sense, instead look in to vickees inbox.
Edit:
The "real" sending of the mail is done by the local MTA (Mail Transfer Agent). This is either sendmail, postfix or any other local service.
It's not part of or task of PHP.
PHP is only passing the mail to the configured MTA (usually locally).
Thus: you need to check your e-mail setup first!

email not going through using the mail() function

I've got a form page on my website where the user has to enter his email ID. As soon as he does that an email should get triggered to him. I've used the mail() function but the email isn't going through. This is on a remote server. Am I missing out on something? Below is the PHP code that I'm using.
<?php
$to  = 'xyz#gmail.com';
$subject = 'Demo mail';
$message = 'This is a demo mail. Please reply to make sure the mail communication is okay.';
$headers = 'From: abc#gmail.com' . "\r\n" .
'Reply-To: abc#gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if (mail($to, $subject, $message, $headers)) {
echo("<p>Email successfully sent!</p>");
} else {
echo("<p>Email delivery failed</p>");
}
?>
 
The output is Email delivery failed!
What is it that I'm supposed to do apart from this? Thank you in advance!
mail() function relies on email configuration of the server the program is running on. You should take a look at your server email configuration, or use a library in order to hook up with an external SMTP service, like Gmail or one of your email servers. I recommend the Swift email library, which is well known, it's thoroughly tested and has a great community behind:
http://swiftmailer.org/
check php.ini config file for SMTP connection or add ini_set("SMTP", "IP_ADDRESS"); in your script.
you can also wrap your script with a error handler to debug the SMTP connection.

PHP mail() not sending email except on gmail

I've written a mail script as;
<?php
$to = 'something#domain.com';
$subject = 'This is subject!';
$body = 'Welcome to our website!';
$headers = 'From: myemail#mydomain.com' . "\r\n" .
'Reply-To: myemail#mydomain.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$sent = mail($to, $subject, $body, $headers);
if($sent) {
echo "Your mail has been sent to ". $to .".";
} else {
echo "You mail was not sent.";
}
?>
And I could see the echo "Your mail has been sent to someone#somedomain.com" for mail being sent in all of the cases regardless of what email is but the emails are being delivered only to something#gmail.com but never on something#hotmail.com or something#yahoo.com or something#domain.com (hosted on google apps).
I wonder if there is any server configuration missing or the server has been blocked for hotmail/yahoomail or any error there is? Is there any thing you guys can help/suggest me for this?
I've configured my cPanel mail to be recieved at google apps, but I think that doesn't matter as I am trying to send mail, not recieve with this code here.
And yes, I've tried checking in the SPAM/JUNK folders and also waited lots of minutes to see them not being delivered. ;(
Hello Please check sender email sendbox also ,there may be mail in sendbox with some error message. or it may be that on your host the reverse DNS wasn't setup correctly..thanks.
You must authenticate your email with your password before sending, so it won't get blocked in the server. if you use mail class like phpmailer to send mails, following example will help you.
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Username = "yourname#yourdomain"; // SMTP account username
$mail->Password = "yourpassword"; // SMTP account password
Php mailer -- Download phpmailer in this website.
SMTP demo -- Nice tutorial how to use php mailer to send authenticated mails.

Sending email from domain different than primary? Possible?

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.

cannot send mail using php mail function

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>

Categories