How to send email to groups in lotus domino server using PHP - php

I have a code in PHP that sends emails to users and its working as expected. I need help in figuring out as how to send email to a group defined in lotus notes. So basically there is a group existing with some name as DEV TEAM and if I type this directly, PHP throws 501 Syntax error, parameters in command..... So, is there a way to figure out as how to retrieve the email address format for this group or any other way to send emails.
I know with all you gurus here, I will get some solution definitely:).
Thanks for any help in advance.
Please let me know if I can provide any other details.
Code through which I am able to send emails to users but not to a group in lotus notes.
<?php
$to = "testuserto#domain.com";
$subject = "TEST EMAIL";
$message = "Hello! Its is test email.";
$from = "testuser#domain.com";
$headers = "From:" . $from . "\r\n";;
$headers .= "Content-Type: text/html";
mail($to,$subject,$message,$headers);
?>

See my comment on your question. If my assumptions are correct, then the administrator of your Domino server must check the following:
DEV TEAM is a valid group in the Domino Directory, with type "Mail Only" or "Multi-Purpose".
There is no readers field on the DEV TEAM group that would restrict anonymous users from sending to it.
There are no mail rules or restrictions in the server's config document that prevent messages from being sent to the group.
The Internet Address field in the DEV TEAM group document in the Domino Directory has been configured. This should be a valid RFC-821 address, such as DEV_TEAM#yourDomain.com (This is probably optional, but it makes it easier to document the solution.)
Once you have confirmed the above configuration information, your code should use the value that was configured in Internet Address field of the DEV TEAM group in the Domino Directory. (I.e., DEV_TEAM#yourDomain.com)

My guess is that is has got very little to do with the fact that it's a Domino server. I assume the address(es) in $from or $to are malformed. See also http://www-01.ibm.com/support/docview.wss?uid=swg21105288, concerning strict RFC821 format, where '<' and '>' are required.
In any case, mail to "dev team#domain.com" won't work, the address is invalid.

Related

PHP: Email will work, but only to 1 of 2 addresses [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
I am working on a PHP script, which I have stripped down to just the emailing function for troubleshooting. My problem is that when I send the email to the desired address, it doesn't go through. However, if I switch the receiver address to my gmail account, it works perfectly. I have sent test emails to the desired address, which go through, and work perfectly.
Note that I have changed the email address below. This does not work.
$emailFrom = "sender#domain.com";
$emailTo = "receiver#domain.com" ;
$emailSubject = "KMV - New Prints Order!";
$emailMessage = "Hello, World!";
$emailHeaders = 'From: '.$emailFrom."\r\n".
'Reply-To: '.$emailFrom."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($emailTo, $emailSubject, $emailMessage, $emailHeaders);
However if I change one line as follows:
$emailTo = "myAddress#gmail.com" ;
It works.
I'm lost as to what could be causing this issue.
The problem is not in your PHP code. You have to debug your postfix or sendmail log in order to dig deeply into the problem. First check in your php.ini what is configured for ' sendmail_path = ' in order to figure out what service (daemon) you are using for sending emails (postfix, sendmail, etc...).
Than find the appropriate log file of this service and analyze it further. Probably your messages are rejected at some point of the SMTP communication.
You can also configure an external mail service (one that is not running on your server and that you do not have to manage yourself) in your php.ini. If you are not going to send large amount of messages you can use gmail or yahoo. Here is a link howto set this up.
https://www.digitalocean.com/community/tutorials/how-to-use-gmail-or-yahoo-with-php-mail-function
If you want to send large amount of messages you have to consider using some sort of external service like mailchimp and mailgun or like office 360 and zoho as someone suggested in the comments above.

pear mail not working

My use of Pear to relay one of our site's users ('sender') email to another user ('recipient') fails because the recipient user always receives the mail in their spam folder. For the explanation below, our website is called "oursite.com."
I have narrowed this down after 2 solid days of lots of experimenting to the "From" part of the 'headers' as follows (for the sake of this example, my name is Sam Hambone and I have no idea how the 'From:' in the title of the email is grabbing my name and using it as described below):
$senderEmail = "IamTheSender#gmail.com";
// this version of the 'from' variable makes the 'From' in the email's title
// look correct, like this: "IamTheSender#gmail.com (IamTheSender#gmail.com)"
// but when the recipient gets the mail, it will ALWAYS go into the 'junk'
// or 'spam' email folder of the recipient's inbox. NOTE: using angle brackets
// instead of parentheses here changes nothing.
$from = $senderEmail . " (" . $senderEmail . ")";
// this second version of 'from' makes the mail arrive correctly
// in the recipient's Inbox and not in their spam/junk folder, but
// the "From:" line in the email's title looks like this:
// "Sam Hambone (IamTheSender#gmail.com)"
$from = $senderEmail;
EDIT: here is what the email's title and headers look like using the 1st version of 'from' above -- in this case I sent an email to myself as the recipient:
'Sender has a question for you, Mr. Recipient!'
Sam Hambone (IamTheSender#gmail.com) << this is wrong -- it's mixing my (recipient)
real name with the sender's email address!!
To: sammyhambone#hotmail.com
From: IamTheSender#gmail.com
Sent: Fri 10/18/13 5:49 PM
To: sammyhambone#hotmail.com (sammyhambone#hotmail.com)
Here is the rest of the code -- this code successfully sends out the email, but by using one of the above versions of the from variable, I either find the email go to the recipient's Junk folder or the 'From:' part in the email's title is screwed up as described above:
$theRecipient = "aLoyalUser#hotmail.com";
$to = $theRecipient . " (" . $theRecipient . ")";
$subject = "the subject is Pear and emailing.";
$body = "Ach, megotts lads, comes the blarney stone."
$host = "smtp.1and1.com";
$port = "25";
$username = "myAuthName#oursite.com";
$password = "12345";
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$headers['From'] = $from; // one of the two 'from' versions given above
$headers['To'] = $to;
$headers['Subject'] = $subject;
$mail = $smtp->send($theRecipient, $headers, $body);
// tried this, no help
$mail = $smtp->send($to, $headers, $body);
I need to get the Sender's email message to the Recipient's Inbox but the "From:" part of the email's title must not say "Sam Hambone (IamTheSender#gmail.com)".
What's missing here?
The best example of a website that probably everyone is familiar with is -- I have noticed that sites like Craigslist are always able to get emails routed to me when I place an ad to sell something (clothes, furniture, etc.)
There are other examples where a website 'relays' one of their user's email to my inbox successfully. That is what I was after, as that is what our site needs to do -- when a user needs to contact another user they send an email through our site (since that's how they came to be aware of the other user) and we need to relay their email to our other user.
No one (yet?) seems to have concrete experience on how to do this, so I'll close out this question in just a bit.
As you may or may not know, there is a war on spam *. This is because spammers are so prolific that they're using a significant amount of resources on servers like processing power (for filtering spam). They also threaten to ruin the usefulness of things like e-mail if we do not stop them. Therefore, because they're a major practical concern, there are all sorts of very sensitive spam filters across the internet that will put you in junk mail for reasons ranging like sending to too many messages that bounce, sending to a particularly unlucky inactive e-mail address (called a spam trap), etc. It is conceivable that the anti-spam software that is running is using this particular e-mail from format as one of it's heuristics to detect spam. It might be argued that using this as a heuristic is irrational or overly-sensitive, but as I've mentioned, the war on spam has resulted in some spam filtering mechanisms that are quite sensitive. If you want to do a test, perhaps try white listing the from e-mail address or turning off the spam filter(s) (in addition to server-side filters, e-mail clients and virus scanners may include some filtering abilities) and see if the spam filter is the culprit.
Update: Now that I am aware of the purpose of this e-mail software (to relay a message sent from the site from one user to another user, while presumably protecting their privacy) I can provide a better suggestion:
The notifications that I receive from websites to tell me that a user has messaged me simply contain the name of the website in the from line rather than a person's name. Example:
Website Name (no-reply#websitename.com)
(Note - it could be important to some spam filters that the website name in the from line matches the domain name exactly.)
If that doesn't seem to make it through the spam filter, I would try the following ideas:
Check out other "from" lines from other websites to see how they're doing it and try out any patterns you find.
Consider signing up with an e-mail reputation service to see whether they can help you.
Test to see whether this quirk is a big issue or a small one by determining which specific piece of spam software is flagging these, and then finding out how many users they have. You could also try sending these e-mails to a variety of other e-mail services to see whether they junk them. It may be that you have some old or unpopular spam filter here that's behaving in a way which actually is not indicative of what will happen to most of your e-mails.
Citation: "Spam Wars" by MIT Technology Review

PHP mailer setting from address in mail function

Ok so I set up a php mailer on 2 separate pages on a site I am working on. I had previously worked through everything in the mailer on a site I built and it was straight forward how to set the email after setting all the variables:
mail("$email",
"Receipt: $thesubject",
"$message",
"From: $replyemail\nReply-To: $replyemail");
So this was what was at the end of the contact (processing) page. I have $email and $replyemail being put into the $message and they come out correctly in the message that gets sent to my email specified by $email.
The part I don't really understand is the address the message says it is coming from is not that $replyemail but instead it says it is being sent from:
rtl.srv#gmail.com
I saw a few posts that were similar but none of them fixed the issue, I followed this and checked to make sure the servers php.ini files had SAFE_MODE = off. Then added
'-f $replyemail'
to the end of the mail function above like that link advised but it didn't change anything... I saw somewhere else that it explained you may have to add the email address to the file /etc/mail/trusted-users but the issue is that email is dynamic. Since that email name is whatever the user input as their email. Then the email is sent to the site admin to review, and I want the email to say it is from the users email that filled out the form.
I know the variables are set correctly because they are being printed out correctly inside the message of the email. So if anyone has any idea why this is happening or how I could go about fixing it I would appreciate any insight.
The project is built in wordpress but I just dropped the files onto the server through SSH, not sure if that has anything to do with it.
Thanks,
-Alan
There are a number of issues that can cause this, and I encountered this issue a while ago when I built my site. I solved it by first creating a function to handle the mailout for me:
function mailouthtml($to, $title, $body, $from){
if(!isset($from)){
$from = 'Default Sender<address#example.com>';
}
$header .= "Reply-To: $from\r\n";
$header .= "Return-Path: $from\r\n";
$header .= "From: $from\r\n";
$header .= "Organization: Example.com, Inc.\r\n";
$header .= "Content-Type: text/html\r\n";
mail($to,$title,$body,$header,"-f $from");
}
Let me break this down a bit. The function calls for a To address, the email title, the email body, and the From address. The From address is used to add information to the email header. The header information of your email is what tells your mail server what to do with your email, and it needs a bit of info in order to handle the message properly.
The mail() function in PHP is formatted as follows:
mail($to,$title,$body,$headers,$additional_parameters);
The mailouthtml() function I've created here constructs the header manually, and adds the additional parameter "-f $from" to set the "From" field explicitly. The $from variable is optional in the function call; if it isn't present, it sets a default. You can find more information on the mail function Here.
Note the following:
Most MTA's require a Reply-To, Return-Path and From field, or it may be flagged as spam.
Content-Type is required tell what type of content the mail server is delivering, typically text/html or text/plain.
I have an if(){} statement that sets a default address if none is specified. You can omit 'Default Sender' if you would rather not specify a name. You can also change that to whatever you'd like.
Organization is optional.
I would also recommend you have SPF enabled on your domain name, and DKIM signing on your messages. These are both implemented via DNS entries for your domain name. If you don't have access to that, no big deal; they're meant to control spam.
Also, if you have a dedicated server and your own IP address, make sure you have a Reverse DNS record set up. This will also help foreign MTA's identify your message as authentic.
don't make this to yourself. Use some mature library like phpmailer or swiftmailer, they will help you to avoid these kind of troubles...I know there are more includes, etc, but there is not point to give fight to this. If you still want to do this, try setting the header Returh-path

PHP mail() function will not send to gmail but will send to my non-gmail account

For some reason the php mail() function is not working properly on a site I am building. I tried to troubleshoot the issue down to its simplest form, and came up with this file:
<?php
mail('myEmail#gmail.com', 'the subject', 'the message', 'From: webmaster#example.com', '-fwebmaster#example.com');
?>
when myEmail is a Gmail account, I never receive the message. However when I use a non-gmail account, I do receive the message. I am at a loss and have tried everything to figure this out. I am starting to think it is an obscure host/server issue. You can see the server specs here: http://aopmfg.com/php.php
Any ideas?
EDIT - let me also add that this was all working fine a few weeks ago, the last time I tested it. No significant code changes since then at all.
EDIT 2 - After reading a similar post I tried adding From and Reply-To headers... still no luck. New code:
<?
$headers = 'From: <some#email.com>' . "\r\n" .
'Reply-To: <some#email.com>';
mail('<myEmail#gmail.com>', 'the subject', 'the message', $headers,
'-fwebmaster#example.com');
?>
It turns out that Google blocked my server because another site on the same server was hacked and used for spam.
To test and ensure that it was a problem with the server, I created a simple PHP file that would send an email to my email address on page refresh. It worked when I sent to my exchange-based email address, but not to any Google-related accounts.
Code:
$headers = 'From: <test#test.com>' . "\r\n" .
'Reply-To: <test#test.com>';
mail('<myEmail#gmail.com>', 'the subject', 'the message', $headers,
'-fwebmaster#example.com');
?>
Thanks for the help all.
Try putting <> around the From and Reply to addresses. I had that same problem with work emails.
I had a similar problem with gmail. However my subject title was "See if you have won". When I changed this to something less marketing/spammy, it came through. So it's not always the PHP code who is causing this, but it can be the subject title as well which is blacklisted.
I was having the same problem. But when I checked my C:\xampp\mailoutput folder, the mail sent was received in this folder. Now please check and do the needful. It was sent in my testing local server. If it is sent on the real server, that may be on your hosting server and you have to check through site hoster
I have found that adding SPF and DKIM records to DNS solved the problem. I can use the phpmail() function to send to a list of Gmail subscribers.
The domain in the email used in the -f option in the php.ini sendmail parameter or in the mail() extra parameters field, needs to have a valid SPF record for the domain.
You should also use a domain key or DKIM. The trick here is that the domain key/DKIM is case sensitive!
After updating the records the mails get delivered to Gmail, Yahoo and AOL addresses.
Read the source here. Comments by ABOMB
https://www.php.net/manual/en/function.mail.php#107321
I had the same problem. I was using a BCC email address to record the messages sent. This is an advantage as if gmail or hotmail blocked the mail then the BCC was also blocked.
I created an SPF record and that did not help on its own though is probably a good idea.
What did seem to help me was putting the email addresses in <> and adding a reply to entry in the header.
$headers = 'From: <test#test.com>' . "\r\n" .
'BCC: <fred#test.com>' . "\r\n" .
'Reply-To: <test#test.com>';
mail('<myEmail#gmail.com>', 'the subject', 'the message', $headers);
gmail canceled the less secure app option .
so now you need to generate a powerfull gmail password that gives who use this password to enter your account without any problem . follow my steps .
1.First go to your google account management and go to security.
2.Make sure your 2-step verification are enabled To your phone or whatever.
3.Then go to search in the gmail manager then search for : app passwords.
4. Select other in the select app dropdown menu, and named whatever you like.
5 then click generate, google will give you a password. make sure you copy it and save it somewhere else.
instead using your real google account password in PHPMailer or laragon etc.. setting, use the password you just generate.
The problem is the BCC option, remove the BCC or -f email, and that's all.

PHP mail not showing up at Gmail but shows up at Hotmail and other 3rd party/ISP account

I have 2 sites where mail is sent to two vanity gmail accounts. I'm using PHP to handle the mail, but the mail is not showing up at gmail (not in spam/junk, it just doesn't show up). If I switch the PHP to send to my personal hotmail account, the mail shows up. Same for a personal email account through my ISP.
The mail used to show up at those 2 vanity gmail accounts, any ideas why they would just stop?
There is a possibility you did not set proper header data, and those emails are blocked even before reaching spam folder.
Try adding something like this:
$headers = 'From: your#email.com' . "\r\n" .
'Reply-To: some#email.com';
This is the fourth parameter of mail() function.
I have encountered problems in the past where certain free email providers would not receive any email from my servers.
I found that a few things can be the culprit, on top of putting the correct headers in the actual message:
Make sure your server is configured for reverse dns lookup
Make sure you are not running an open smtp relay
Make sure your server did not wind up in any email blacklists (if you had an open relay, you probably got blacklisted.
Chances are, PHP is sending the email just fine, but the Google servers are rejecting any messages coming from your server.
You can test this by doing a quick:
mail -s Test you#gmail.com < /dev/null
If your server is okay, you will receive a message in your gmail, if you don't, PHP isn't the problem.
I've found having a proper SPF record for your domain really helps
http://www.openspf.org/SPF_Record_Syntax
Seems more likely that this is a server configuration issue and not a PHP issue.
As a side note I've found gmail more tolerant than our local system, so I've been able to get messages out to my gmail account, but not my account on the hosting domain.
I don't think Google uses third-party black lists, but they do care about server configuration (does it identify itself correctly, have matching SPF and RDNS records, respond to commands properly). You might try a couple of testing services like this or this.
I see it is too late but ... following code is working for gmail.
<html>
Mail Responder:<br><br>
<?php
$to = $_REQUEST['MyEmail'] ;
$subject = $_REQUEST['subject'] ;
$greeting = $_REQUEST['greeting'] ;
$realname = $_REQUEST['realname'] ;
$HisEmail = $_REQUEST['HisEmail'] ;
$message = $_REQUEST['message'] ;
$headers = 'From: '.$HisEmail;
//$headers = 'From: $HisEmail' . "\r\n" .
//'Reply-To: some#email.com';
$send = mail($to, $subject, $greeting."\n"."\n".$realname."\n"."\n".$HisEmail."\n"."\n".$message, $headers );
if ($send)
$mailReturns = "Mail sent successfully.";
else
$mailReturns = "Mail sent failed.";
?>
<?php echo $mailReturns; ?>
</html>

Categories